Beispiel #1
0
/**
* Send a quick http request locally if we need to process cron events (to each of the cron entry points)
* 
* This only runs events on 15-minute intervals and tries to keep it close to the clock increments (00, 15, 30, 45)
* 
*/
function CheckCron()
{
    // open and lock the cron job file - abandon quickly if we can't get a lock
    $should_run = false;
    $minutes15 = false;
    $minutes60 = false;
    $cron_lock = Lock("Cron Check", false, 1200);
    if (isset($cron_lock)) {
        $last_run = 0;
        if (is_file('./tmp/wpt_cron.dat')) {
            $last_run = file_get_contents('./tmp/wpt_cron.dat');
        }
        $now = time();
        $elapsed = $now - $last_run;
        if (!$last_run) {
            $should_run = true;
            $minutes15 = true;
            $minutes60 = true;
        } elseif ($elapsed > 120) {
            if ($elapsed > 1200) {
                // if it has been over 20 minutes, run regardless of the wall-clock time
                $should_run = true;
            } else {
                $minute = gmdate('i', $now) % 5;
                if ($minute < 2) {
                    $should_run = true;
                    $minute = gmdate('i', $now) % 15;
                    if ($minute < 2) {
                        $minutes15 = true;
                    }
                    $minute = gmdate('i', $now) % 60;
                    if ($minute < 2) {
                        $minutes60 = true;
                    }
                }
            }
        }
        if ($should_run) {
            file_put_contents('./tmp/wpt_cron.dat', $now);
        }
        Unlock($cron_lock);
    }
    // send the cron requests
    if ($should_run) {
        if (is_file('./settings/benchmarks/benchmarks.txt') && is_file('./benchmarks/cron.php')) {
            SendAsyncRequest('/benchmarks/cron.php');
        }
        SendAsyncRequest('/cron/5min.php');
        if (is_file('./jpeginfo/cleanup.php')) {
            SendAsyncRequest('/jpeginfo/cleanup.php');
        }
        if ($minutes15) {
            SendAsyncRequest('/cron/15min.php');
        }
        if ($minutes60) {
            SendAsyncRequest('/cron/hourly.php');
        }
    }
}
                        }
                    }
                }
                if ($testInfo_dirty) {
                    SaveTestInfo($id, $testInfo);
                }
                SecureDir($testPath);
                UnlockTest($testLock);
                /*************************************************************************
                 * Do No modify TestInfo after this point
                 **************************************************************************/
                // do any post-processing when the full test is complete that doesn't rely on testinfo
                if ($done) {
                    logTestMsg($id, "Test Complete");
                    // send an async request to the post-processing code so we don't block
                    SendAsyncRequest("/work/postprocess.php?test={$id}");
                }
            } else {
                logMsg("location key incorrect\n");
            }
        }
    }
}
$workdone_end = microtime(true);
/*
if (isset($workdone_video_start) && isset($workdone_video_end)) {
  $elapsed = intval(($workdone_end - $workdone_start) * 1000);
  $video_elapsed = intval(($workdone_video_end - $workdone_video_start) * 1000);
  if ($video_elapsed > 10)
    logMsg("$elapsed ms - video processing: $video_elapsed ms - Test $id, Run $runNumber:$cacheWarmed", './work/workdone.log', true);
}
Beispiel #3
0
             } else {
                 $exists = true;
             }
         }
         if (!$exists) {
             // set up the result directory
             $dest = './' . GetVideoPath($id);
             if (!is_dir($dest)) {
                 mkdir($dest, 0777, true);
             }
             if (count($labels)) {
                 file_put_contents("{$dest}/labels.txt", json_encode($labels));
             }
             gz_file_put_contents("{$dest}/testinfo.json", json_encode($tests));
             // kick off the actual rendering
             SendAsyncRequest("/video/render.php?id={$id}");
         }
     }
 }
 // redirect to the destination page
 if ($id) {
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
     $host = $_SERVER['HTTP_HOST'];
     $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
     if ($xml) {
         header('Content-type: text/xml');
         echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
         echo "<response>\n";
         echo "<statusCode>200</statusCode>\n";
         echo "<statusText>Ok</statusText>\n";
         if (strlen($_REQUEST['r'])) {