diff --git a/README.md b/README.md index e33bd92..798e5c8 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ _A web interface for this version is currently in development, if you want to kn You must have the following installed in order to run php-resque: * [Redis](http://redis.io/) -* [PHP 5.3+](http://php.net/) +* [PHP 7.1+](http://php.net/) * [PCNTL PHP extension](http://php.net/manual/en/book.pcntl.php) * [Composer](http://getcomposer.org/) @@ -81,7 +81,7 @@ Add php-resque to your application's `composer.json` file: ```json { "require": { - "mjphaynes/php-resque": "2.1.*" + "mjphaynes/php-resque": "3.0.*" } } ``` diff --git a/composer.json b/composer.json index cec84da..6758761 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,12 @@ } ], "require": { - "php": ">=5.3.0", + "php": ">=7.1.0", "ext-pcntl": "*", "predis/predis": "1.1.*", "monolog/monolog": "~1.7", - "symfony/console": "~2.7|~3.0", - "symfony/yaml": "~2.7|~3.0" + "symfony/console": "~3.0|~4.0|~5.0", + "symfony/yaml": "~3.0|~4.0|~5.0" }, "suggest": { "ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker in PHP versions < 5.5.0.", @@ -26,7 +26,7 @@ }, "require-dev": { "phpunit/phpunit": "~4.8", - "symfony/process": "~2.7|~3.0" + "symfony/process": "~3.0|~4.0|~5.0" }, "bin": [ "bin/resque" diff --git a/src/Resque/Commands/Cleanup.php b/src/Resque/Commands/Cleanup.php index 18bc785..c2a82f9 100644 --- a/src/Resque/Commands/Cleanup.php +++ b/src/Resque/Commands/Cleanup.php @@ -13,10 +13,8 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -51,5 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->log('Cleaned workers: '.json_encode(array_merge($cleaned_hosts['workers'], $cleaned_workers)).''); $this->log('Cleaned '.$cleaned_jobs['zombie'].' zombie job'.($cleaned_jobs['zombie'] == 1 ? '' : 's')); $this->log('Cleared '.$cleaned_jobs['processed'].' processed job'.($cleaned_jobs['processed'] == 1 ? '' : 's')); + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Clear.php b/src/Resque/Commands/Clear.php index a4e72c7..4f11b4e 100644 --- a/src/Resque/Commands/Clear.php +++ b/src/Resque/Commands/Clear.php @@ -13,10 +13,8 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; @@ -55,6 +53,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } $output->writeln('Done.'); + + return self::SUCCESS; } } } diff --git a/src/Resque/Commands/Command.php b/src/Resque/Commands/Command.php index 1cbcdb2..32a489d 100644 --- a/src/Resque/Commands/Command.php +++ b/src/Resque/Commands/Command.php @@ -13,10 +13,8 @@ use Resque; use Resque\Helpers\Util; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -26,6 +24,9 @@ */ class Command extends \Symfony\Component\Console\Command\Command { + public const SUCCESS = 0; + public const FAILURE = 1; + public const INVALID = 2; /** * @var Logger The logger instance diff --git a/src/Resque/Commands/Hosts.php b/src/Resque/Commands/Hosts.php index 7df4e7f..37dc226 100644 --- a/src/Resque/Commands/Hosts.php +++ b/src/Resque/Commands/Hosts.php @@ -13,9 +13,7 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; @@ -56,5 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $this->log((string)$table); + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Job/Queue.php b/src/Resque/Commands/Job/Queue.php index 1445c2b..f3e2478 100644 --- a/src/Resque/Commands/Job/Queue.php +++ b/src/Resque/Commands/Job/Queue.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -70,21 +69,23 @@ protected function execute(InputInterface $input, OutputInterface $output) $delay = (int)$delay; } else { $this->log('Delay option "'.$delay.'" is invalid type "'.gettype($delay).'", value must be an integer.', Logger::ERROR); - return; + return self::INVALID; } if ($delay) { if ($job = Resque::later($delay, $job, $args, $queue)) { $this->log('Job '.$job.' will be queued at '.date('r', $job->getDelayedTime()).' on '.$job->getQueue().' queue.'); - return; + return self::SUCCESS; } } else { if ($job = Resque::push($job, $args, $queue)) { $this->log('Job '.$job.' added to '.$job->getQueue().' queue.'); - return; + return self::SUCCESS; } } $this->log('Error, job was not queued. Please try again.', Logger::ERROR); + + return self::FAILURE; } } diff --git a/src/Resque/Commands/Queues.php b/src/Resque/Commands/Queues.php index 2bf84f8..050857b 100644 --- a/src/Resque/Commands/Queues.php +++ b/src/Resque/Commands/Queues.php @@ -13,10 +13,8 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -63,5 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $this->log((string)$table); + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Socket/Connect.php b/src/Resque/Commands/Socket/Connect.php index 61afd34..0a789b0 100644 --- a/src/Resque/Commands/Socket/Connect.php +++ b/src/Resque/Commands/Socket/Connect.php @@ -13,10 +13,8 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -112,5 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } fclose($fh); + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Socket/Receive.php b/src/Resque/Commands/Socket/Receive.php index 425046c..12073d1 100644 --- a/src/Resque/Commands/Socket/Receive.php +++ b/src/Resque/Commands/Socket/Receive.php @@ -14,7 +14,6 @@ use Resque; use Resque\Job; use Resque\Host; -use Resque\Redis; use Resque\Worker; use Resque\Socket; use Resque\Helpers\Util; @@ -23,7 +22,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\OutputInterface; @@ -285,6 +283,8 @@ protected function execute(InputInterface $input, OutputInterface $output) }); $server->run(); + + return self::SUCCESS; } public function pollingConsoleOutput() diff --git a/src/Resque/Commands/Socket/Send.php b/src/Resque/Commands/Socket/Send.php index 7786e02..5907a5e 100644 --- a/src/Resque/Commands/Socket/Send.php +++ b/src/Resque/Commands/Socket/Send.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -74,5 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->log(''.trim($response).''); fclose($fh); + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/SpeedTest.php b/src/Resque/Commands/SpeedTest.php index 059e258..3a04ca3 100644 --- a/src/Resque/Commands/SpeedTest.php +++ b/src/Resque/Commands/SpeedTest.php @@ -13,13 +13,10 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\Process; -use Symfony\Component\Console\Helper\ProgressBar; use Exception; @@ -76,6 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output) foreach ($keys as $key) { $redis->del($key); } + + return self::SUCCESS; } // http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html diff --git a/src/Resque/Commands/Worker/Cancel.php b/src/Resque/Commands/Worker/Cancel.php index 52079dc..34a44d6 100644 --- a/src/Resque/Commands/Worker/Cancel.php +++ b/src/Resque/Commands/Worker/Cancel.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -48,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($id) { if (false === ($worker = Resque\Worker::hostWorker($id))) { $this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR); - return; + return self::FAILURE; } $workers = array($worker); @@ -74,5 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->log('Worker '.$worker.' has no running job.'); } } + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Worker/Pause.php b/src/Resque/Commands/Worker/Pause.php index 22c967f..ba0f13c 100644 --- a/src/Resque/Commands/Worker/Pause.php +++ b/src/Resque/Commands/Worker/Pause.php @@ -15,8 +15,6 @@ use Resque\Commands\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -48,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($id) { if (false === ($worker = Resque\Worker::hostWorker($id))) { $this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR); - return; + return self::FAILURE; } $workers = array($worker); @@ -67,5 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->log('Worker '.$worker.' could not send USR2 signal.'); } } + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Worker/Restart.php b/src/Resque/Commands/Worker/Restart.php index 3265ea6..7a4af7e 100644 --- a/src/Resque/Commands/Worker/Restart.php +++ b/src/Resque/Commands/Worker/Restart.php @@ -15,8 +15,6 @@ use Resque\Commands\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -48,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($id) { if (false === ($worker = Resque\Worker::hostWorker($id))) { $this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR); - return; + return self::FAILURE; } $workers = array($worker); @@ -89,6 +87,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - exit(0); + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Worker/Resume.php b/src/Resque/Commands/Worker/Resume.php index e51b141..85b0ab4 100644 --- a/src/Resque/Commands/Worker/Resume.php +++ b/src/Resque/Commands/Worker/Resume.php @@ -15,8 +15,6 @@ use Resque\Commands\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -67,5 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->log('Worker '.$worker.' could not send CONT signal.'); } } + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Worker/Start.php b/src/Resque/Commands/Worker/Start.php index 57ed5ff..4371baf 100644 --- a/src/Resque/Commands/Worker/Start.php +++ b/src/Resque/Commands/Worker/Start.php @@ -13,10 +13,8 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -71,6 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } $worker->work(); + + return self::SUCCESS; } public function pollingConsoleOutput() diff --git a/src/Resque/Commands/Worker/Stop.php b/src/Resque/Commands/Worker/Stop.php index 248752a..1c73124 100644 --- a/src/Resque/Commands/Worker/Stop.php +++ b/src/Resque/Commands/Worker/Stop.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -49,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($id) { if (false === ($worker = Resque\Worker::hostWorker($id))) { $this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR); - return; + return self::FAILURE; } $workers = array($worker); @@ -70,5 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->log('Worker '.$worker.' could not send '.$sig.' signal.'); } } + + return self::SUCCESS; } } diff --git a/src/Resque/Commands/Workers.php b/src/Resque/Commands/Workers.php index db578d9..15b1375 100644 --- a/src/Resque/Commands/Workers.php +++ b/src/Resque/Commands/Workers.php @@ -13,10 +13,8 @@ use Resque; use Resque\Commands\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -68,5 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $this->log((string)$table); + + return self::SUCCESS; } }