*/
public static function killStaleWorkers()
{
- $stamp = (float)microtime(true);
$entries = DBA::select(
'workerqueue',
['id', 'pid', 'executed', 'priority', 'command', 'parameter'],
while ($entry = DBA::fetch($entries)) {
if (!posix_kill($entry["pid"], 0)) {
- $stamp = (float)microtime(true);
DBA::update(
'workerqueue',
['executed' => DBA::NULL_DATETIME, 'pid' => 0],
// Define the maximum durations
$max_duration_defaults = [PRIORITY_CRITICAL => 720, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 720];
- $max_duration = $max_duration_defaults[$entry['priority']];
+ $max_duration = $max_duration_defaults[$entry['priority']];
$argv = json_decode($entry['parameter'], true);
if (!empty($entry['command'])) {
} elseif ($entry['priority'] != PRIORITY_CRITICAL) {
$new_priority = PRIORITY_NEGLIGIBLE;
}
- $stamp = (float)microtime(true);
DBA::update(
'workerqueue',
['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
DI::lock()->release(Worker::LOCK_PROCESS);
}
}
- }
+ }
/**
* Directly deliver AP messages or requeue them.
- *
+ *
* This function is placed here as a safeguard. Even when the worker queue is completely blocked, messages will be delivered.
*/
private static function deliverPosts()
return false;
}
- $pid = intval(file_get_contents($pidfile));
+ $pid = intval(file_get_contents($pidfile));
$running = posix_kill($pid, 0);
self::$daemon_mode = $running;
private static function spawn()
{
Logger::notice('Starting new daemon process');
- $command = 'bin/daemon.php';
- $a = DI::app();
- DI::system()->run($command, ['start']);
+ DI::system()->run('bin/daemon.php', ['start']);
Logger::notice('New daemon process started');
}
}