Update to use the sanity interval for the lock

This commit is contained in:
pxgamer
2018-10-29 17:44:15 +00:00
parent 88f50fcae1
commit 7e11df5a28

View File

@@ -31,6 +31,8 @@ if (php_sapi_name() !== 'cli') {
die("This should only be run as cli"); die("This should only be run as cli");
} }
require_once __DIR__.'/include/init.inc.php';
// make sure there's only a single sanity process running at the same time // make sure there's only a single sanity process running at the same time
if (file_exists("tmp/sanity-lock")) { if (file_exists("tmp/sanity-lock")) {
$ignore_lock = false; $ignore_lock = false;
@@ -40,15 +42,18 @@ if (file_exists("tmp/sanity-lock")) {
$ignore_lock = true; $ignore_lock = true;
} }
} }
$pid_time = filemtime("tmp/sanity-lock"); $pid_time = filemtime(__DIR__."/tmp/sanity-lock");
// if the process died, restart after 1day
if (time() - $pid_time > 86400) { // If the process died, restart after 3 times the sanity interval
@unlink("tmp/sanity-lock"); if (time() - $pid_time > ($_config['sanity_interval'] * 3)) {
@unlink(__DIR__."/tmp/sanity-lock");
} }
if (!$ignore_lock) { if (!$ignore_lock) {
die("Sanity lock in place"); die("Sanity lock in place");
} }
} }
// set the new sanity lock // set the new sanity lock
$lock = fopen("tmp/sanity-lock", "w"); $lock = fopen("tmp/sanity-lock", "w");
fclose($lock); fclose($lock);
@@ -60,8 +65,6 @@ if ($arg != "microsanity") {
sleep(3); sleep(3);
} }
require_once __DIR__.'/include/init.inc.php';
if ($argv[1]=="dev") { if ($argv[1]=="dev") {
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE); error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
ini_set("display_errors", "on"); ini_set("display_errors", "on");