Changeset 196386 in webkit


Ignore:
Timestamp:
Feb 10, 2016 1:05:37 PM (8 years ago)
Author:
rniwa@webkit.org
Message:

Add the support for maintenance mode
https://bugs.webkit.org/show_bug.cgi?id=154072

Reviewed by Chris Dumez.

Added the crude support for maintenance mode whereby which the reports are stored in the filesystem
instead of the database.

  • config.json: Added maintenanceMode and maintenanceDirectory as well as forgotten siteTitle and

remoteServer.httpdMutexDir.

  • public/api/report.php:

(main): Don't connect to the database or modify database when maintenanceMode is set.

  • public/include/json-header.php:

(ensure_privileged_api_data): Exit with InMaintenanceMode when maintenanceMode is set. This prevents
privileged API such as creating analysis tasks and new A/B testing groups from modifying the database.

Location:
trunk/Websites/perf.webkit.org
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/perf.webkit.org/ChangeLog

    r196333 r196386  
     12016-02-10  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Add the support for maintenance mode
     4        https://bugs.webkit.org/show_bug.cgi?id=154072
     5
     6        Reviewed by Chris Dumez.
     7
     8        Added the crude support for maintenance mode whereby which the reports are stored in the filesystem
     9        instead of the database.
     10
     11        * config.json: Added maintenanceMode and maintenanceDirectory as well as forgotten siteTitle and
     12        remoteServer.httpdMutexDir.
     13        * public/api/report.php:
     14        (main): Don't connect to the database or modify database when maintenanceMode is set.
     15        * public/include/json-header.php:
     16        (ensure_privileged_api_data): Exit with InMaintenanceMode when maintenanceMode is set. This prevents
     17        privileged API such as creating analysis tasks and new A/B testing groups from modifying the database.
     18
    1192016-02-09  Ryosuke Niwa  <rniwa@webkit.org>
    220
  • trunk/Websites/perf.webkit.org/config.json

    r196195 r196386  
    11{
     2    "siteTitle": "WebKit Performance Dashboard",
    23    "debug": true,
    34    "jsonCacheMaxAge": 600,
     
    1011        "name": "webkit-perf-db"
    1112    },
     13    "maintenanceMode": false,
     14    "maintenanceDirectory": "reported/",
    1215    "testServer": {
    1316        "hostname": "localhost",
     
    2124        "httpdPID": "tools/remote-server-relay.pid",
    2225        "httpdErrorLog": "tools/remote-server-relay.log",
    23         "url": "http://perf.webkit.org",
     26        "httpdMutexDir": "/tmp/org.webkit.perf.remote/",
     27        "url": "https://perf-safari.apple.com",
    2428        "basicAuth": {
    2529            "username": "username",
  • trunk/Websites/perf.webkit.org/public/api/report.php

    r163688 r196386  
    88    set_exit_detail('failureStored', false);
    99
     10    $maintenance_mode = config('maintenanceMode');
     11    if ($maintenance_mode && !config('maintenanceDirectory'))
     12        exit_with_error('MaintenanceDirectoryNotSet');
     13
    1014    $db = new Database;
    11     if (!$db->connect())
     15    if (!$maintenance_mode && !$db->connect())
    1216        exit_with_error('DatabaseConnectionFailure');
    1317
     
    2024    set_exit_detail('processedRuns', 0);
    2125    foreach ($parsed_json as $i => $report) {
    22         $processor = new ReportProcessor($db);
    23         $processor->process($report);
     26        if (!$maintenance_mode) {
     27            $processor = new ReportProcessor($db);
     28            $processor->process($report);
     29        }
    2430        set_exit_detail('processedRuns', $i + 1);
    2531    }
    2632
    27     $generator = new ManifestGenerator($db);
    28     if (!$generator->generate())
    29         exit_with_error('FailedToGenerateManifest');
    30     else if (!$generator->store())
    31         exit_with_error('FailedToStoreManifest');
     33    if ($maintenance_mode) {
     34        $files = scandir(config_path('maintenanceDirectory', ''));
     35        $i = 0;
     36        $filename = '';
     37        do {
     38            $i++;
     39            $filename = "$i.json";
     40        } while (in_array($filename, $files));
     41        file_put_contents(config_path('maintenanceDirectory', $filename), $post_data, LOCK_EX);
     42    } else {
     43        $generator = new ManifestGenerator($db);
     44        if (!$generator->generate())
     45            exit_with_error('FailedToGenerateManifest');
     46        else if (!$generator->store())
     47            exit_with_error('FailedToStoreManifest');
     48    }
    3249
    3350    exit_with_success();
  • trunk/Websites/perf.webkit.org/public/include/json-header.php

    r194130 r196386  
    9292function ensure_privileged_api_data() {
    9393    global $HTTP_RAW_POST_DATA;
     94
     95    if (config('maintenanceMode'))
     96        exit_with_error('InMaintenanceMode');
    9497
    9598    if ($_SERVER['REQUEST_METHOD'] != 'POST')
Note: See TracChangeset for help on using the changeset viewer.