@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | protected function execute(InputInterface $input, OutputInterface $output) |
| 50 | 50 | { |
| 51 | - $pidFile = $this->params->get('kernel.cache_dir').'/resque_scheduledworker.pid'; |
|
| 51 | + $pidFile = $this->params->get('kernel.cache_dir') . '/resque_scheduledworker.pid'; |
|
| 52 | 52 | if (file_exists($pidFile) && !$input->getOption('force')) { |
| 53 | 53 | throw new \Exception('PID file exists - use --force to override'); |
| 54 | 54 | } |
@@ -60,31 +60,31 @@ discard block |
||
| 60 | 60 | $env = [ |
| 61 | 61 | 'APP_INCLUDE' => $this->params->get('resque.app_include'), |
| 62 | 62 | 'VVERBOSE' => 1, |
| 63 | - 'RESQUE_PHP' => $this->params->get('resque.vendor_dir').'/chrisboulton/php-resque/lib/Resque.php', |
|
| 63 | + 'RESQUE_PHP' => $this->params->get('resque.vendor_dir') . '/chrisboulton/php-resque/lib/Resque.php', |
|
| 64 | 64 | 'INTERVAL' => $input->getOption('interval'), |
| 65 | 65 | ]; |
| 66 | 66 | |
| 67 | 67 | if (!file_exists($env['RESQUE_PHP'])) { |
| 68 | - $env['RESQUE_PHP'] = $this->params->get('resque.vendor_dir').'/resque/php-resque/lib/Resque.php'; |
|
| 68 | + $env['RESQUE_PHP'] = $this->params->get('resque.vendor_dir') . '/resque/php-resque/lib/Resque.php'; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if (false !== getenv('APP_INCLUDE')) { |
| 72 | 72 | $env['APP_INCLUDE'] = getenv('APP_INCLUDE'); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $prefix = $this->params->get('resque.prefix'); |
|
| 75 | + $prefix = $this->params->get('resque.prefix'); |
|
| 76 | 76 | |
| 77 | 77 | if (!empty($prefix)) { |
| 78 | - $env['PREFIX'] = $this->params->get('resque.prefix'); |
|
| 78 | + $env['PREFIX'] = $this->params->get('resque.prefix'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $redisHost = $this->params->get('resque.redis.host'); |
|
| 82 | - $redisPort = $this->params->get('resque.redis.port'); |
|
| 83 | - $redisDatabase = $this->params->get('resque.redis.database'); |
|
| 84 | - $redisPassword = $this->params->get('resque.redis.password'); |
|
| 81 | + $redisHost = $this->params->get('resque.redis.host'); |
|
| 82 | + $redisPort = $this->params->get('resque.redis.port'); |
|
| 83 | + $redisDatabase = $this->params->get('resque.redis.database'); |
|
| 84 | + $redisPassword = $this->params->get('resque.redis.password'); |
|
| 85 | 85 | |
| 86 | 86 | if (null != $redisHost && null != $redisPort) { |
| 87 | - $env['REDIS_BACKEND'] = $redisHost.':'.$redisPort; |
|
| 87 | + $env['REDIS_BACKEND'] = $redisHost . ':' . $redisPort; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if (isset($redisDatabase)) { |
@@ -98,20 +98,20 @@ discard block |
||
| 98 | 98 | if (version_compare(PHP_VERSION, '5.4.0') >= 0) { |
| 99 | 99 | $phpExecutable = PHP_BINARY; |
| 100 | 100 | } else { |
| 101 | - $phpExecutable = PHP_BINDIR.'/php'; |
|
| 101 | + $phpExecutable = PHP_BINDIR . '/php'; |
|
| 102 | 102 | if (\defined('PHP_WINDOWS_VERSION_BUILD')) { |
| 103 | 103 | $phpExecutable = 'php'; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $workdirectory = __DIR__.'/../bin/'; |
|
| 108 | - $workerCommand = $phpExecutable.' '.$workdirectory.'resque-scheduler'; |
|
| 107 | + $workdirectory = __DIR__ . '/../bin/'; |
|
| 108 | + $workerCommand = $phpExecutable . ' ' . $workdirectory . 'resque-scheduler'; |
|
| 109 | 109 | |
| 110 | 110 | if (!$input->getOption('foreground')) { |
| 111 | - $logFile = $this->params->get( |
|
| 111 | + $logFile = $this->params->get( |
|
| 112 | 112 | 'kernel.logs_dir' |
| 113 | - ).'/resque-scheduler_'.$this->params->get('kernel.environment').'.log'; |
|
| 114 | - $workerCommand = 'nohup '.$workerCommand.' > '.$logFile.' 2>&1 & echo $!'; |
|
| 113 | + ) . '/resque-scheduler_' . $this->params->get('kernel.environment') . '.log'; |
|
| 114 | + $workerCommand = 'nohup ' . $workerCommand . ' > ' . $logFile . ' 2>&1 & echo $!'; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // In windows: When you pass an environment to CMD it replaces the old environment |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | // this is a workaround where we add the vars to the existing environment. |
| 120 | 120 | if (\defined('PHP_WINDOWS_VERSION_BUILD')) { |
| 121 | 121 | foreach ($env as $key => $value) { |
| 122 | - putenv($key.'='.$value); |
|
| 122 | + putenv($key . '=' . $value); |
|
| 123 | 123 | } |
| 124 | 124 | $env = null; |
| 125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $output->writeln(sprintf('Starting worker <info>%s</info>', $process->getCommandLine())); |
| 130 | 130 | |
| 131 | 131 | if ($input->getOption('foreground')) { |
| 132 | - $process->run(function ($type, $buffer) use ($output) { |
|
| 132 | + $process->run(function($type, $buffer) use ($output) { |
|
| 133 | 133 | $output->write($buffer); |
| 134 | 134 | }); |
| 135 | 135 | } // else we recompose and display the worker id |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | protected function execute(InputInterface $input, OutputInterface $output) |
| 43 | 43 | { |
| 44 | - $pidFile = $this->params->get('kernel.cache_dir').'/resque_scheduledworker.pid'; |
|
| 44 | + $pidFile = $this->params->get('kernel.cache_dir') . '/resque_scheduledworker.pid'; |
|
| 45 | 45 | |
| 46 | 46 | if (!file_exists($pidFile)) { |
| 47 | 47 | $output->writeln('No PID file found'); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $pid = file_get_contents($pidFile); |
| 53 | 53 | |
| 54 | - $output->writeln('Killing process '.$pid); |
|
| 54 | + $output->writeln('Killing process ' . $pid); |
|
| 55 | 55 | |
| 56 | 56 | posix_kill($pid, SIGKILL); |
| 57 | 57 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | ]; |
| 93 | 93 | |
| 94 | 94 | if (!isset($password)) { |
| 95 | - \Resque::setBackend($host.':'.$port, $database); |
|
| 95 | + \Resque::setBackend($host . ':' . $port, $database); |
|
| 96 | 96 | } else { |
| 97 | 97 | $server = 'redis://:' . $password . '@' . $host . ':' . $port; |
| 98 | 98 | \Resque::setBackend($server, $database); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function getQueues() |
| 265 | 265 | { |
| 266 | - return array_map(function ($queue) { |
|
| 266 | + return array_map(function($queue) { |
|
| 267 | 267 | return new Queue($queue); |
| 268 | 268 | }, \Resque::queues()); |
| 269 | 269 | } |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | public function getWorkers() |
| 285 | 285 | { |
| 286 | - return array_map(function ($worker) { |
|
| 286 | + return array_map(function($worker) { |
|
| 287 | 287 | return new Worker($worker); |
| 288 | 288 | }, \Resque_Worker::all()); |
| 289 | 289 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function getRunningWorkers() |
| 295 | 295 | { |
| 296 | - return array_filter($this->getWorkers(), function (Worker $worker) { |
|
| 296 | + return array_filter($this->getWorkers(), function(Worker $worker) { |
|
| 297 | 297 | return null !== $worker->getCurrentJob(); |
| 298 | 298 | }); |
| 299 | 299 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | //TODO: find a more efficient way to do this |
| 371 | 371 | $out = []; |
| 372 | 372 | foreach ($timestamps as $timestamp) { |
| 373 | - $out[] = [$timestamp, \Resque::redis()->llen('delayed:'.$timestamp)]; |
|
| 373 | + $out[] = [$timestamp, \Resque::redis()->llen('delayed:' . $timestamp)]; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | return $out; |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | */ |
| 392 | 392 | public function getJobsForTimestamp($timestamp) |
| 393 | 393 | { |
| 394 | - $jobs = \Resque::redis()->lrange('delayed:'.$timestamp, 0, -1); |
|
| 394 | + $jobs = \Resque::redis()->lrange('delayed:' . $timestamp, 0, -1); |
|
| 395 | 395 | $out = []; |
| 396 | 396 | foreach ($jobs as $job) { |
| 397 | 397 | $out[] = json_decode($job, true); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | protected function createKernel() |
| 57 | 57 | { |
| 58 | 58 | $finder = new Finder(); |
| 59 | - $finder->name('*Kernel.php')->depth('<=1')->in($this->args['kernel.project_dir'].'/src'); |
|
| 59 | + $finder->name('*Kernel.php')->depth('<=1')->in($this->args['kernel.project_dir'] . '/src'); |
|
| 60 | 60 | $results = iterator_to_array($finder); |
| 61 | 61 | $file = current($results); |
| 62 | 62 | $class = $file->getBasename('.php'); |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | // Take into account any namespace |
| 65 | 65 | preg_match('/namespace\s(.*)\;/', file_get_contents($file), $matches); |
| 66 | 66 | if (2 == \count($matches)) { |
| 67 | - $namespace = '\\'.$matches[1].'\\'; |
|
| 68 | - $class = $namespace.$class; |
|
| 67 | + $namespace = '\\' . $matches[1] . '\\'; |
|
| 68 | + $class = $namespace . $class; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | require_once $file; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $count = $queue->clear(); |
| 77 | 77 | $queue->remove(); |
| 78 | 78 | |
| 79 | - $this->addFlash('info', 'Remove '.$queue->getName().' queue and '.$count.' jobs.'); |
|
| 79 | + $this->addFlash('info', 'Remove ' . $queue->getName() . ' queue and ' . $count . ' jobs.'); |
|
| 80 | 80 | |
| 81 | 81 | return $this->redirectToRoute('ResqueBundle_homepage'); |
| 82 | 82 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $count = $this->resque->retryFailedJobs(); |
| 185 | 185 | |
| 186 | - $this->addFlash('info', 'Retry '.$count.' failed jobs.'); |
|
| 186 | + $this->addFlash('info', 'Retry ' . $count . ' failed jobs.'); |
|
| 187 | 187 | |
| 188 | 188 | return $this->redirectToRoute('ResqueBundle_homepage'); |
| 189 | 189 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $count = $this->resque->retryFailedJobs(true); |
| 197 | 197 | |
| 198 | - $this->addFlash('info', 'Retry and clear '.$count.' failed jobs.'); |
|
| 198 | + $this->addFlash('info', 'Retry and clear ' . $count . ' failed jobs.'); |
|
| 199 | 199 | |
| 200 | 200 | return $this->redirectToRoute('ResqueBundle_homepage'); |
| 201 | 201 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | $count = $this->resque->clearFailedJobs(); |
| 209 | 209 | |
| 210 | - $this->addFlash('info', 'Clear '.$count.' failed jobs.'); |
|
| 210 | + $this->addFlash('info', 'Clear ' . $count . ' failed jobs.'); |
|
| 211 | 211 | |
| 212 | 212 | return $this->redirectToRoute('ResqueBundle_homepage'); |
| 213 | 213 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getId() |
| 45 | 45 | { |
| 46 | - return (string) $this->worker; |
|
| 46 | + return (string)$this->worker; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function getQueues() |
| 53 | 53 | { |
| 54 | - return array_map(function ($queue) { |
|
| 54 | + return array_map(function($queue) { |
|
| 55 | 55 | return new Queue($queue); |
| 56 | 56 | }, $this->worker->queues()); |
| 57 | 57 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function getJobs($start = 0, $stop = -1) |
| 49 | 49 | { |
| 50 | - $jobs = \Resque::redis()->lrange('queue:'.$this->name, $start, $stop); |
|
| 50 | + $jobs = \Resque::redis()->lrange('queue:' . $this->name, $start, $stop); |
|
| 51 | 51 | |
| 52 | 52 | $result = []; |
| 53 | 53 | foreach ($jobs as $job) { |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function clear() |
| 70 | 70 | { |
| 71 | - $length = \Resque::redis()->llen('queue:'.$this->name); |
|
| 72 | - \Resque::redis()->del('queue:'.$this->name); |
|
| 71 | + $length = \Resque::redis()->llen('queue:' . $this->name); |
|
| 72 | + \Resque::redis()->del('queue:' . $this->name); |
|
| 73 | 73 | |
| 74 | 74 | return $length; |
| 75 | 75 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $configuration = new Configuration(); |
| 29 | 29 | $config = $this->processConfiguration($configuration, $configs); |
| 30 | 30 | |
| 31 | - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 31 | + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 32 | 32 | $loader->load('services.xml'); |
| 33 | 33 | |
| 34 | 34 | $container->setParameter('resque.vendor_dir', $config['vendor_dir']); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | if (method_exists($treeBuilder, 'getRootNode')) { |
| 29 | 29 | // Symfony 4+ |
| 30 | - $root = $treeBuilder->getRootNode(); |
|
| 30 | + $root = $treeBuilder->getRootNode(); |
|
| 31 | 31 | } else { |
| 32 | 32 | // Symfony 3 |
| 33 | 33 | $root = $treeBuilder->root('resque'); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | ->arrayNode('auto_retry') |
| 57 | 57 | ->beforeNormalization() |
| 58 | 58 | ->ifArray() |
| 59 | - ->then(function ($var) { |
|
| 59 | + ->then(function($var) { |
|
| 60 | 60 | if (\array_key_exists(0, $var)) { |
| 61 | 61 | return [$var]; |
| 62 | 62 | } |