From 16f88a6a38541a8793d9dd35ddce6e6c0f79ab92 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 3 Aug 2016 17:07:52 +0200 Subject: [PATCH] Move declare(ticks = 1) to startup Having declare(ticks = 1) inside registerSigHandlers() worked perfectly on PHP 5.6 but it doesn't on PHP 7. I found it that moving the declare(ticks = 1) outside registerSigHandlers() solves the issue. --- lib/Resque/Worker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index 973d7fd..cd96062 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -311,6 +311,8 @@ class Resque_Worker */ private function startup() { + declare(ticks = 1); + $this->registerSigHandlers(); $this->pruneDeadWorkers(); Resque_Event::trigger('beforeFirstFork', $this); @@ -349,7 +351,6 @@ class Resque_Worker return; } - declare(ticks = 1); pcntl_signal(SIGTERM, array($this, 'shutDownNow')); pcntl_signal(SIGINT, array($this, 'shutDownNow')); pcntl_signal(SIGQUIT, array($this, 'shutdown'));