ENHANCEMENT: daemon cannot be checked if run in a different container
This commit is contained in:
parent
9fea685e86
commit
53424c50bf
|
@ -50,7 +50,7 @@ class DaemonCommand extends Command
|
|||
throw new \InvalidArgumentException('Time limit has incorrect value');
|
||||
}
|
||||
$jobRepo->unlockJob();
|
||||
file_put_contents($this->kernel->getCacheDir() . '/daemon-running.lock', posix_getpid());
|
||||
file_put_contents($this->kernel->getCacheDir() . '/daemon-running.lock', time());
|
||||
while(1) {
|
||||
if($endofscript !== false && time() > $endofscript) break;
|
||||
|
||||
|
@ -86,6 +86,7 @@ class DaemonCommand extends Command
|
|||
}
|
||||
}
|
||||
$this->doctrine->getManager()->clear();
|
||||
file_put_contents($this->kernel->getCacheDir() . '/daemon-running.lock', time());
|
||||
|
||||
$maxwait = time() + 30;
|
||||
$nextrun = $jobRepo->getTimeOfNextRun();
|
||||
|
|
|
@ -14,8 +14,8 @@ class DaemonHelpers
|
|||
*/
|
||||
public static function isProcessRunning($pidFile = '/var/run/myfile.pid') {
|
||||
if (!file_exists($pidFile) || !is_file($pidFile)) return false;
|
||||
$pid = file_get_contents($pidFile);
|
||||
$return = posix_kill((int)$pid, 0);
|
||||
$lasttick = file_get_contents($pidFile);
|
||||
$return = ((int)$lasttick >= (time() - 30));
|
||||
if (!$return) unlink($pidFile);
|
||||
return $return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue