Permalink
Browse files

Do not run queue workers while application is in maintenance mode.

  • Loading branch information...
taylorotwell committed Oct 31, 2013
1 parent aa6df0a commit a8cdb683a097e04281ada784d9073c8a83f72bf1
Showing with 18 additions and 1 deletion.
  1. +2 −1 src/Illuminate/Foundation/changes.json
  2. +16 −0 src/Illuminate/Queue/Console/WorkCommand.php
@@ -62,6 +62,7 @@
{"message": "Added Cookie::queue method for creating cookies that are automatically attached to the final response.", "backport": null},
{"message": "Allow environment to be checked via App::environment method.", "backport": null},
{"message": "Add support for order by and limit on MySQL update queries.", "backport": null},
{"message": "Tweak Container::resolve to accept a type, new resolvingAny method for all objects.", "backport": null}
{"message": "Tweak Container::resolve to accept a type, new resolvingAny method for all objects.", "backport": null},
{"message": "Do not run queue workers while application is in maintenance mode.", "backport": null}
]
}
@@ -48,6 +48,8 @@ public function __construct(Worker $worker)
*/
public function fire()
{
if ($this->downForMaintenance()) return;
$queue = $this->option('queue');
$delay = $this->option('delay');
@@ -62,6 +64,18 @@ public function fire()
$this->worker->pop($connection, $queue, $delay, $memory, $this->option('sleep'));
}
/**
* Determine if the worker should run in maintenance mode.
*
* @return bool
*/
protected function downForMaintenance()
{
if ($this->option('force')) return false;
return $this->laravel->isDownForMaintenance();
}
/**
* Get the console command arguments.
*
@@ -86,6 +100,8 @@ protected function getOptions()
array('delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0),
array('force', null, InputOption::VALUE_NONE, 'Force the worker to run even in maintenance mode.'),
array('memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128),
array('sleep', null, InputOption::VALUE_OPTIONAL, 'Number of seconds to sleep when no job is available', 3),

0 comments on commit a8cdb68

Please sign in to comment.