X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FWorker.php;h=d43d8c7281008198beac9b812ee9bd160fbf9d56;hb=4724000d06cd47bd5eee97111f2723962007d3dc;hp=cee1c655210fb0b296fa9d7d5a076acabcfd0f11;hpb=38f70cc55ad1d99b011fa92b42361c39ecceb2e3;p=friendica.git diff --git a/src/Core/Worker.php b/src/Core/Worker.php index cee1c65521..d43d8c7281 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -1,6 +1,6 @@ UTC_TIMESTAMP() - INTERVAL ? MINUTE", $interval]); + $jobs = DBA::count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - ' . $interval . ' minute')]); self::$db_duration += (microtime(true) - $stamp); self::$db_duration_stat += (microtime(true) - $stamp); $jobs_per_minute[$interval] = number_format($jobs / $interval, 0); @@ -846,7 +846,7 @@ class Worker private static function activeWorkers() { $stamp = (float)microtime(true); - $count = DBA::count('process', ['command' => 'Worker.php']); + $count = DI::process()->countCommand('Worker.php'); self::$db_duration += (microtime(true) - $stamp); self::$db_duration_count += (microtime(true) - $stamp); return $count; @@ -1182,23 +1182,23 @@ class Worker // We now are in the new worker DBA::connect(); - /// @todo Reinitialize the logger to set a new process_id and uid - $process = DI::process()->create($pid); + DI::flushLogger(); + $process = DI::process()->create(getmypid(), basename(__FILE__)); $cycles = 0; - while (!self::IPCJobsExists($pid) && (++$cycles < 100)) { + while (!self::IPCJobsExists($process->pid) && (++$cycles < 100)) { 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::unclaimProcess($process); - self::IPCSetJobState(false, $pid); + self::IPCSetJobState(false, $process->pid); DI::process()->delete($process); - Logger::info('Worker ended', ['pid' => $pid]); + Logger::info('Worker ended', ['pid' => $process->pid]); exit(); }