Fix PID at forking

This commit is contained in:
Philipp 2021-10-31 20:23:23 +01:00
parent 32f0c3fb9c
commit a7487ee50d
No known key found for this signature in database
GPG key ID: 24A7501396EB5432

View file

@ -1183,22 +1183,22 @@ class Worker
DBA::connect(); DBA::connect();
DI::flushLogger(); DI::flushLogger();
$process = DI::process()->create($pid); $process = DI::process()->create(getmypid());
$cycles = 0; $cycles = 0;
while (!self::IPCJobsExists($pid) && (++$cycles < 100)) { while (!self::IPCJobsExists($process->pid) && (++$cycles < 100)) {
usleep(10000); usleep(10000);
} }
Logger::info('Worker spawned', ['pid' => $pid, 'wait_cycles' => $cycles]); Logger::info('Worker spawned', ['pid' => $process->pid, 'wait_cycles' => $cycles]);
self::processQueue($do_cron, $process); self::processQueue($do_cron, $process);
self::unclaimProcess($process); self::unclaimProcess($process);
self::IPCSetJobState(false, $pid); self::IPCSetJobState(false, $process->pid);
DI::process()->delete($process); DI::process()->delete($process);
Logger::info('Worker ended', ['pid' => $pid]); Logger::info('Worker ended', ['pid' => $process->pid]);
exit(); exit();
} }