X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fworker.php;h=2995775db1b18e05a12ad099994d838f96e3ae75;hb=6319d9671c9924617ccd11077190b6fc74b3f5a8;hp=d6ecbecc264935036eb1427e72f65f9c4da3ad62;hpb=920160cb28135e33b35a9ada579ca5393be000a5;p=friendica.git diff --git a/mod/worker.php b/mod/worker.php index d6ecbecc26..2995775db1 100644 --- a/mod/worker.php +++ b/mod/worker.php @@ -4,11 +4,14 @@ * @brief Module for running the worker as frontend process */ -use Friendica\Core\Worker; use Friendica\Core\Config; -use Friendica\Core\PConfig; +use Friendica\Core\Logger; +use Friendica\Core\Worker; +use Friendica\Database\DBA; +use Friendica\Util\DateTimeFormat; -function worker_init($a){ +function worker_init() +{ if (!Config::get("system", "frontend_worker")) { return; @@ -29,19 +32,22 @@ function worker_init($a){ return; } - $a->start_process(); + Worker::startProcess(); - logger("Front end worker started: ".getmypid()); + Logger::log("Front end worker started: ".getmypid()); Worker::callWorker(); - if ($r = Worker::workerProcess()) { + $passing_slow = false; + if ($r = Worker::workerProcess($passing_slow)) { // On most configurations this parameter wouldn't have any effect. // But since it doesn't destroy anything, we just try to get more execution time in any way. set_time_limit(0); - if (poller_claim_process($r[0])) { + $fields = ['executed' => DateTimeFormat::utcNow(), 'pid' => getmypid(), 'done' => false]; + $condition = ['id' => $r[0]["id"], 'pid' => 0]; + if (DBA::update('workerqueue', $fields, $condition)) { Worker::execute($r[0]); } } @@ -50,9 +56,9 @@ function worker_init($a){ Worker::unclaimProcess(); - $a->end_process(); + Worker::endProcess(); - logger("Front end worker ended: ".getmypid()); + Logger::log("Front end worker ended: ".getmypid()); - killme(); + exit(); }