protected function retryJob($jid, $queue = false) { /** @var Job $job */ $job = $this->client->getJobs()->get($jid); if ($job) { $opts = []; if ($queue) { $opt['queue'] = $queue; } $job->requeue($opts); } return $this->client->get($jid); }
private function watchdogStart() { $socket = null; $this->watchdogPID = $this->fork($socket); if ($this->watchdogPID !== 0) { $this->sockets[$this->watchdogPID] = $socket; return; } $this->processType = self::PROCESS_TYPE_WATCHDOG; $this->clearSigHandlers(); $jid = $this->job->getId(); $this->who = 'watchdog:' . $this->workerName; $this->logContext = ['type' => $this->who]; $status = 'watching events for ' . $jid . ' since ' . strftime('%F %T'); $this->updateProcLine($status); $this->logger->info($status, $this->logContext); ini_set("default_socket_timeout", -1); $l = $this->client->createListener(['ql:log']); $l->messages(function ($channel, $event) use($l, $jid) { if (!in_array($event->event, ['lock_lost', 'canceled', 'completed', 'failed']) || $event->jid !== $jid) { return; } switch ($event->event) { case 'lock_lost': if ($event->worker === $this->workerName) { $this->logger->info("{type}: sending SIGKILL to child {$this->childPID}; job handed out to another worker", $this->logContext); posix_kill($this->childPID, SIGKILL); $l->stop(); } break; case 'canceled': if ($event->worker === $this->workerName) { $this->logger->info("{type}: sending SIGKILL to child {$this->childPID}; job canceled", $this->logContext); posix_kill($this->childPID, SIGKILL); $l->stop(); } break; case 'completed': case 'failed': $l->stop(); break; } }); socket_close($socket); $this->logger->info("{type}: done", $this->logContext); exit(0); }