2016-07-28 21:52:05 +00:00
|
|
|
<?php
|
|
|
|
namespace Hlgrrnhrdt\Resque;
|
|
|
|
|
|
|
|
use Config;
|
|
|
|
use Hlgrrnhrdt\Resque\Console\WorkCommand;
|
2016-07-29 11:49:06 +00:00
|
|
|
use Illuminate\Contracts\Foundation\Application;
|
2016-07-28 21:52:05 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-07-29 11:49:06 +00:00
|
|
|
|
|
|
|
|
2016-07-28 21:52:05 +00:00
|
|
|
protected function registerManager()
|
|
|
|
{
|
2016-07-29 11:49:06 +00:00
|
|
|
$this->app->singleton('resque.manager', function (Application $app) {
|
2016-07-28 21:52:05 +00:00
|
|
|
$config = $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
|
|
|
|
|
|
|
return new ResqueManager($resque, $app['config']['resque.trackStatus']);
|
2016-07-28 21:52:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function registerWorkCommand()
|
|
|
|
{
|
2016-07-29 11:49:06 +00:00
|
|
|
$this->app->singleton('command.resque.work', function (Application $app) {
|
|
|
|
return new WorkCommand($app->make('resque.manager'));
|
2016-07-28 21:52:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|