#!/usr/bin/env php 1) { $count = $COUNT; } // Determines redis key prefix $PREFIX = getenv('PREFIX'); if (!empty($PREFIX)) { $logger->log(\Psr\Log\LogLevel::INFO, 'Prefix set to {prefix}', ['prefix' => $PREFIX]); \Resque\Redis::prefix($PREFIX); } if ($count > 1) { for ($i = 0; $i < $count; ++$i) { $pid = \Resque\Resque::fork(); if ($pid === false || $pid === -1) { $logger->log(\Psr\Log\LogLevel::EMERGENCY, 'Could not fork worker {count}', ['count' => $i]); die(); } elseif (!$pid) { // Child, start the worker $queues = explode(',', $QUEUE); $worker = new \Resque\Worker($queues); $worker->setLogger($logger); $logger->log(\Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', ['worker' => $worker]); $worker->work($interval, $BLOCKING); break; } } } else { // Start a single worker $queues = explode(',', $QUEUE); $worker = new \Resque\Worker($queues); $worker->setLogger($logger); $PIDFILE = getenv('PIDFILE'); if ($PIDFILE) { file_put_contents($PIDFILE, getmypid()) or die('Could not write PID information to ' . $PIDFILE); } $logger->log(\Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', ['worker' => $worker]); $worker->work($interval, $BLOCKING); }