diff --git a/Command/StartScheduledWorkerCommand.php b/Command/StartScheduledWorkerCommand.php index 5c8559b..c6a4355 100644 --- a/Command/StartScheduledWorkerCommand.php +++ b/Command/StartScheduledWorkerCommand.php @@ -33,12 +33,16 @@ protected function execute(InputInterface $input, OutputInterface $output) } $env = array( - 'APP_INCLUDE' => $this->getContainer()->getParameter('kernel.root_dir').'/../var/bootstrap.php.cache', + 'APP_INCLUDE' => $this->getContainer()->getParameter('resque.app_include'), 'VVERBOSE' => 1, 'RESQUE_PHP' => $this->getContainer()->getParameter('resque.vendor_dir').'/chrisboulton/php-resque/lib/Resque.php', 'INTERVAL' => $input->getOption('interval'), ); + if (false !== getenv('APP_INCLUDE')) { + $env['APP_INCLUDE'] = getenv('APP_INCLUDE'); + } + $prefix = $this->getContainer()->getParameter('resque.prefix'); if (!empty($prefix)) { $env['PREFIX'] = $this->getContainer()->getParameter('resque.prefix'); diff --git a/Command/StartWorkerCommand.php b/Command/StartWorkerCommand.php index c91be6a..e8e24e5 100644 --- a/Command/StartWorkerCommand.php +++ b/Command/StartWorkerCommand.php @@ -41,12 +41,16 @@ protected function execute(InputInterface $input, OutputInterface $output) ); } - $env['APP_INCLUDE'] = $this->getContainer()->getParameter('kernel.root_dir').'/../var/bootstrap.php.cache'; + $env['APP_INCLUDE'] = $this->getContainer()->getParameter('resque.app_include'); $env['COUNT'] = $input->getOption('count'); $env['INTERVAL'] = $input->getOption('interval'); $env['QUEUE'] = $input->getArgument('queues'); $env['VERBOSE'] = 1; + if (false !== getenv('APP_INCLUDE')) { + $env['APP_INCLUDE'] = getenv('APP_INCLUDE'); + } + $prefix = $this->getContainer()->getParameter('resque.prefix'); if (!empty($prefix)) { $env['PREFIX'] = $this->getContainer()->getParameter('resque.prefix'); diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php index a417721..5ec1169 100644 --- a/Controller/DefaultController.php +++ b/Controller/DefaultController.php @@ -3,6 +3,7 @@ namespace Mpclarkson\ResqueBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; class DefaultController extends Controller { @@ -18,9 +19,9 @@ public function indexAction() ); } - public function showQueueAction($queue) + public function showQueueAction($queue, Request $request) { - list($start, $count, $showingAll) = $this->getShowParameters(); + list($start, $count, $showingAll) = $this->getShowParameters($request); $queue = $this->getResque()->getQueue($queue); $jobs = $queue->getJobs($start, $count); @@ -39,9 +40,9 @@ public function showQueueAction($queue) ); } - public function listFailedAction() + public function listFailedAction(Request $request) { - list($start, $count, $showingAll) = $this->getShowParameters(); + list($start, $count, $showingAll) = $this->getShowParameters($request); $jobs = $this->getResque()->getFailedJobs($start, $count); @@ -97,15 +98,17 @@ protected function getResque() /** * decide which parts of a job queue to show * + * @param Request $request + * * @return array */ - private function getShowParameters() + private function getShowParameters(Request $request) { $showingAll = false; $start = -100; $count = -1; - if ($this->getRequest()->query->has('all')) { + if ($request->query->has('all')) { $start = 0; $count = -1; $showingAll = true; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 353c429..59fa556 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -28,6 +28,11 @@ public function getConfigTreeBuilder() ->cannotBeEmpty() ->info('Set the vendor dir') ->end() + ->scalarNode('app_include') + ->defaultValue('%kernel.root_dir%/bootstrap.php.cache') + ->cannotBeEmpty() + ->info('Set the APP_INCLUDE for php-resque') + ->end() ->scalarNode('prefix') ->defaultNull() ->end() diff --git a/DependencyInjection/ResqueExtension.php b/DependencyInjection/ResqueExtension.php index b01e037..fed9e90 100644 --- a/DependencyInjection/ResqueExtension.php +++ b/DependencyInjection/ResqueExtension.php @@ -26,6 +26,7 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('services.xml'); $container->setParameter('resque.vendor_dir', $config['vendor_dir']); + $container->setParameter('resque.app_include', $config['app_include']); $container->setParameter('resque.class', $config['class']); $container->setParameter('resque.redis.host', $config['redis']['host']); $container->setParameter('resque.redis.port', $config['redis']['port']); diff --git a/README.markdown b/README.markdown index 2f30a79..5748f0f 100644 --- a/README.markdown +++ b/README.markdown @@ -124,6 +124,7 @@ You may want to add some configuration to your `config.yml` resque: class: Mpclarkson\ResqueBundle\Resque # the resque class if different from default vendor_dir: %kernel.root_dir%/../vendor # the vendor dir if different from default + app_include: /pathto/bootstrap.php.cache # app include file if different from default prefix: my-resque-prefix # optional prefix to separate Resque data per site/app redis: host: localhost # the redis host diff --git a/bin/resque b/bin/resque index b2e34bf..53bbd31 100755 --- a/bin/resque +++ b/bin/resque @@ -7,7 +7,15 @@ if (empty($QUEUE)) { } require __DIR__ . '/../../../../app/autoload.php'; -require __DIR__ . '/../../../../var/bootstrap.php.cache'; + +$APP_INCLUDE = getenv('APP_INCLUDE'); +if ($APP_INCLUDE) { + if (!file_exists($APP_INCLUDE)) { + die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n"); + } + + require_once $APP_INCLUDE; +} $REDIS_BACKEND = getenv('REDIS_BACKEND'); $REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB'); @@ -29,15 +37,6 @@ if (!empty($LOGGING) || !empty($VERBOSE)) { $logLevel = true; } -$APP_INCLUDE = getenv('APP_INCLUDE'); -if ($APP_INCLUDE) { - if (!file_exists($APP_INCLUDE)) { - die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n"); - } - - require_once $APP_INCLUDE; -} - // See if the APP_INCLUDE containes a logger object, // If none exists, fallback to internal logger if (!isset($logger) || !is_object($logger)) { diff --git a/bin/resque-scheduler b/bin/resque-scheduler index 6603586..e5c8da4 100755 --- a/bin/resque-scheduler +++ b/bin/resque-scheduler @@ -2,7 +2,16 @@ =2.8,<4.0", + "symfony/console": ">=2.8,<4.0", + "symfony/process": ">=2.8,<4.0", "chrisboulton/php-resque": "dev-master#df69e8980cc21652f10cd775cb6a0e8c572ffd2d", "chrisboulton/php-resque-scheduler": "dev-master#ab8bd52949cac1f815bbb97aa39f51c7b5766a86" },