2016-07-28 21:52:05 +00:00
|
|
|
<?php
|
|
|
|
namespace Hlgrrnhrdt\Resque;
|
|
|
|
|
|
|
|
use Hlgrrnhrdt\Resque\Console\WorkCommand;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
use Resque;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ResqueServiceProvider
|
|
|
|
*
|
|
|
|
* @author Holger Reinhardt <hlgrrnhrdt@gmail.com>
|
|
|
|
*/
|
|
|
|
class ResqueServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Register the service provider.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
$this->registerManager();
|
|
|
|
$this->registerWorkCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function registerManager()
|
|
|
|
{
|
2016-07-29 12:05:07 +00:00
|
|
|
$this->app->singleton('resque.manager', function () {
|
|
|
|
$config = $this->app['config']['resque.connection'];
|
2016-07-29 11:49:06 +00:00
|
|
|
|
2016-07-28 21:52:05 +00:00
|
|
|
$resque = new Resque();
|
|
|
|
$resque->setBackend(implode(':', [$config['host'], $config['port']]), $config['db']);
|
2016-07-29 11:49:06 +00:00
|
|
|
|
2016-07-29 12:05:07 +00:00
|
|
|
return new ResqueManager($resque, $this->app['config']['resque.trackStatus']);
|
2016-07-28 21:52:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function registerWorkCommand()
|
|
|
|
{
|
2016-07-29 12:05:07 +00:00
|
|
|
$this->app->singleton('command.resque.work', function () {
|
|
|
|
return new WorkCommand($this->app->make('resque.manager'));
|
2016-07-28 21:52:05 +00:00
|
|
|
});
|
2016-07-29 12:02:56 +00:00
|
|
|
$this->commands('command.resque.work');
|
2016-07-28 21:52:05 +00:00
|
|
|
}
|
|
|
|
}
|