+ Logger::info("Sleeping", ["pid" => $pid]);
+ $start = time();
+ do {
+ $seconds = (time() - $start);
+
+ // logarithmic wait time calculation.
+ // Background: After jobs had been started, they often fork many workers.
+ // To not waste too much time, the sleep period increases.
+ $arg = (($seconds + 1) / ($wait_interval / 9)) + 1;
+ $sleep = round(log10($arg) * 1000000, 0);
+ usleep($sleep);
+
+ $timeout = ($seconds >= $wait_interval);
+ } while (!$timeout && !Worker::IPCJobsExists());
+
+ if ($timeout) {
+ $do_cron = true;
+ Logger::info("Woke up after $wait_interval seconds.", ["pid" => $pid, 'sleep' => $wait_interval]);
+ } else {
+ $do_cron = false;
+ Logger::info("Worker jobs are calling to be forked.", ["pid" => $pid]);