From 16f88a6a38541a8793d9dd35ddce6e6c0f79ab92 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 3 Aug 2016 17:07:52 +0200 Subject: [PATCH 1/2] 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')); From 91caca7921b52000d2c49b3a3bec4a3d35774984 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 3 Aug 2016 20:40:30 +0200 Subject: [PATCH 2/2] Move declare(ticks = 1) to top --- lib/Resque/Worker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index cd96062..94e0e28 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -1,4 +1,6 @@ registerSigHandlers(); $this->pruneDeadWorkers(); Resque_Event::trigger('beforeFirstFork', $this);