From 3cb7a7606e6a2bfc4d46dfa4c5de3cddd9bb8e86 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 11 Jul 2018 06:05:22 +0000 Subject: [PATCH] workaround for stalling worker processes when running the daemon --- bin/daemon.php | 6 ++++-- bin/worker.php | 1 - src/Core/Worker.php | 2 +- src/Model/GContact.php | 9 +++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index f7dcce1642..1abb701462 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -106,8 +106,10 @@ if (!$foreground) { } fclose(STDIN); // Close all of the standard - fclose(STDOUT); // file descriptors as we - fclose(STDERR); // are running as a daemon. + + // Enabling this seem to block a running php process with 100% CPU usage when there is an outpout + // fclose(STDOUT); // file descriptors as we + // fclose(STDERR); // are running as a daemon. dba::disconnect(); diff --git a/bin/worker.php b/bin/worker.php index b4b265283c..44980961cf 100755 --- a/bin/worker.php +++ b/bin/worker.php @@ -63,4 +63,3 @@ Worker::unclaimProcess(); Worker::endProcess(); killme(); - diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 296d40b504..5f19870897 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -597,7 +597,7 @@ class Worker ['id' => $entry["id"]] ); } else { - logger("Worker process ".$entry["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); + logger("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); } } } diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 99660ba602..d77e81a4c7 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -564,15 +564,16 @@ class GContact if (strlen(Config::get('system', 'directory'))) { $x = Network::fetchUrl(get_server()."/pubsites"); - if ($x) { + if (!empty($x)) { $j = json_decode($x); - if ($j->entries) { + if (!empty($j->entries)) { foreach ($j->entries as $entry) { PortableContact::checkServer($entry->url); $url = $entry->url . '/poco'; - if (! in_array($url, $done)) { - PortableContact::loadWorker(0, 0, 0, $entry->url . '/poco'); + if (!in_array($url, $done)) { + PortableContact::loadWorker(0, 0, 0, $url); + $done[] = $url; } } }