mirror of
https://github.com/friendica/friendica
synced 2024-12-22 17:20:16 +00:00
Check for childf status
This commit is contained in:
parent
d70d180e4b
commit
74d7d7e164
2 changed files with 21 additions and 9 deletions
|
@ -223,6 +223,9 @@ while (true) {
|
|||
$sleep = min(1000000, round(log10($arg) * 1000000, 0));
|
||||
usleep($sleep);
|
||||
|
||||
$pid = pcntl_waitpid(-1, $status, WNOHANG);
|
||||
Logger::info('Checked children status via pcntl_waitpid', ['pid' => $pid, 'status' => $status]);
|
||||
|
||||
$timeout = ($seconds >= $wait_interval);
|
||||
} while (!$timeout && !Worker::IPCJobsExists());
|
||||
|
||||
|
|
|
@ -1230,6 +1230,17 @@ class Worker
|
|||
|
||||
DI::process()->end();
|
||||
Logger::info('Worker ended', ['cron' => $do_cron, 'pid' => getmypid()]);
|
||||
|
||||
DBA::disconnect();
|
||||
/*
|
||||
$php = '/usr/bin/php';
|
||||
$param = ['bin/worker.php'];
|
||||
if ($do_cron) {
|
||||
$param[] = 'no_cron';
|
||||
}
|
||||
pcntl_exec($php, $param);
|
||||
Logger::warning('Error calling worker', ['cron' => $do_cron, 'pid' => getmypid()]);
|
||||
*/
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -1242,21 +1253,14 @@ class Worker
|
|||
*/
|
||||
public static function spawnWorker($do_cron = false)
|
||||
{
|
||||
Logger::notice("Spawn", ['do_cron' => $do_cron, 'callstack' => System::callstack(20)]);
|
||||
// Worker and daemon are started from the command line.
|
||||
// This means that this is executed by a PHP interpreter without runtime limitations
|
||||
if (function_exists('pcntl_fork') && in_array(DI::mode()->getExecutor(), [Mode::DAEMON, Mode::WORKER])) {
|
||||
if (self::isDaemonMode()) {
|
||||
self::forkProcess($do_cron);
|
||||
self::IPCSetJobState(false);
|
||||
} else {
|
||||
$process = new Core\Process(DI::logger(), DI::mode(), DI::config(),
|
||||
DI::modelProcess(), DI::app()->getBasePath(), getmypid());
|
||||
$process->run('bin/worker.php', ['no_cron' => !$do_cron]);
|
||||
}
|
||||
|
||||
// after spawning we have to remove the flag.
|
||||
if (self::isDaemonMode()) {
|
||||
self::IPCSetJobState(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1515,6 +1519,11 @@ class Worker
|
|||
return $daemon_mode;
|
||||
}
|
||||
|
||||
if (!function_exists('pcntl_fork')) {
|
||||
self::$daemon_mode = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
$pidfile = DI::config()->get('system', 'pidfile');
|
||||
if (empty($pidfile)) {
|
||||
// No pid file, no daemon
|
||||
|
|
Loading…
Reference in a new issue