public function testGetWorkerById() { $worker = new Resque_Worker('*'); $worker->registerWorker(); $newWorker = Resque_Worker::find((string) $worker); $this->assertEquals((string) $worker, (string) $newWorker); }
protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('all')) { $workers = \Resque_Worker::all(); } else { $worker = \Resque_Worker::find($input->getArgument('id')); if (!$worker) { $availableWorkers = \Resque_Worker::all(); if (!empty($availableWorkers)) { throw new \RuntimeException('A running worker must be specified'); } } $workers = $worker ? array($worker) : array(); } if (count($workers) <= 0) { $output->writeln(array('No workers running', '')); return; } $signal = $input->getOption('force') ? SIGTERM : SIGQUIT; foreach ($workers as $worker) { $output->writeln(sprintf('%s %s...', $signal === SIGTERM ? 'Force stopping' : 'Stopping', $worker)); list(, $pid) = explode(':', (string) $worker); posix_kill($pid, $signal); } $output->writeln(''); }
public function getWorker($id) { $worker = \Resque_Worker::find($id); if (!$worker) { return null; } return new Worker($worker); }