// restart script // a forked process may inherit our lock, but we prevent this. flock($thislockfp, LOCK_UN); fclose($thislockfp); passthru(PHP_CLI . " " . BASE_FILE . "capture/stream/dmitcat_{$role}.php > /dev/null 2>&1 &"); $thislockfp = script_lock('controller'); } } } } if (!$running) { if (script_lock($role, true) === true) { logit("controller.log", "script {$role} was not running - starting"); // record confirmed gap if we could measure it if ($last) { gap_record($role, $last, time()); } // a forked process may inherit our lock, but we prevent this. flock($thislockfp, LOCK_UN); fclose($thislockfp); passthru(PHP_CLI . " " . BASE_FILE . "capture/stream/dmitcat_{$role}.php > /dev/null 2>&1 &"); $thislockfp = script_lock('controller'); } } } function read_procfile($filename) { $procfile = array(); $n = 0; for (;;) { $contents = file_get_contents($filename);
if (script_lock($role, true) === true) { // restart script // a forked process may inherit our lock, but we prevent this. flock($thislockfp, LOCK_UN); fclose($thislockfp); passthru(PHP_CLI . " " . __DIR__ . "/dmitcat_{$role}.php > /dev/null 2>&1 &"); $thislockfp = script_lock('controller'); } } } } if (!$running) { if (script_lock($role, true) === true) { logit("controller.log", "script {$role} was not running - starting"); // record confirmed gap if we could measure it if ($last && gap_record($role, $last, time())) { logit("controller.log", "recording a data gap for script {$role} from '" . toDateTime($last) . "' to '" . toDateTime(time()) . "'"); } else { logit("controller.log", "we have no information about previous running time of script {$role} - cannot record a gap"); } // a forked process may inherit our lock, but we prevent this. flock($thislockfp, LOCK_UN); fclose($thislockfp); passthru(PHP_CLI . " " . __DIR__ . "/dmitcat_{$role}.php > /dev/null 2>&1 &"); $thislockfp = script_lock('controller'); } } } function read_procfile($filename) { $procfile = array();