From 10b035b51ad8f0d1e418dd372b86004e638894ba Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 2 Jan 2021 19:33:50 +0000 Subject: [PATCH] Additional worker cooldown --- src/Core/Worker.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 2f39a82fe..1759fae19 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -411,6 +411,12 @@ class Worker { $a = DI::app(); + $cooldown = DI::config()->get("system", "worker_cooldown", 0); + if ($cooldown > 0) { + Logger::info('Pre execution cooldown.', ['priority' => $queue["priority"], 'id' => $queue["id"], 'cooldown' => $cooldown]); + sleep($cooldown); + } + Logger::enableWorker($funcname); Logger::info("Process start.", ['priority' => $queue["priority"], 'id' => $queue["id"]]); @@ -483,10 +489,8 @@ class Worker DI::profiler()->saveLog(DI::logger(), "ID " . $queue["id"] . ": " . $funcname); - $cooldown = DI::config()->get("system", "worker_cooldown", 0); - if ($cooldown > 0) { - Logger::info('Cooldown.', ['priority' => $queue["priority"], 'id' => $queue["id"], 'cooldown' => $cooldown]); + Logger::info('Post execution cooldown.', ['priority' => $queue["priority"], 'id' => $queue["id"], 'cooldown' => $cooldown]); sleep($cooldown); } }