public function setUp() { parent::setUp(); // Register a worker to test with $this->worker = new Resque_Worker('jobs'); $this->worker->setLogger(new Resque_Log()); }
private function work() { $worker = new \Resque_Worker(explode(',', $this->queue)); if ($this->logger instanceof LoggerInterface) { $worker->setLogger($this->logger); } if (method_exists($worker, 'setStayAlive')) { $worker->setStayAlive($this->stayAlive); } fwrite(STDOUT, '*** Starting worker ' . $worker . "\n"); $worker->work($this->checker_interval, $this->blocking); }
/** * @todo - Clean this up, for now, prune dead workers, just in case */ public function pruneDeadWorkers() { $worker = new \Resque_Worker('temp'); $worker->setLogger(new NullLogger()); $worker->pruneDeadWorkers(); }
public function testBlockingListPop() { $worker = new Resque_Worker('jobs'); $worker->setLogger(new Resque_Log()); $worker->registerWorker(); Resque::enqueue('jobs', 'Test_Job_1'); Resque::enqueue('jobs', 'Test_Job_2'); $i = 1; while ($job = $worker->reserve(true, 1)) { $this->assertEquals('Test_Job_' . $i, $job->payload['class']); if ($i == 2) { break; } $i++; } $this->assertEquals(2, $i); }
public function pruneDeadWorkers() { // HACK, prune dead workers, just in case $worker = new \Resque_Worker('temp'); $worker->setLogger(new NullLogger()); $worker->pruneDeadWorkers(); }
/** * Start a single worker * * @param bool $isForked - is this worker forked */ protected function startWorker($isForked = false) { $queues = explode(',', $this->queue); $worker = new Resque_Worker($queues); $worker->setLogger($this->logger); if (!$isForked) { $PIDFILE = getenv('PIDFILE'); if ($PIDFILE) { file_put_contents($PIDFILE, getmypid()) or die('Could not write PID information to ' . $PIDFILE); } } fwrite(STDOUT, '[+] Starting worker ' . $worker . " " . $this->interval . PHP_EOL); $worker->work($this->interval); }