/** * Get a class for a record by its table's name * @param string $tableName * @throws \Exception * @return string */ public function getClassForRecord($tableName) { $class = $this->namespace . '\\' . $tableName; if (class_exists($class)) { return $class; } else { if ($this->fallback) { return parent::getClassForRecord($tableName); } else { throw new \Exception("Missing class '{$class}' for table '{$tableName}'"); } } }
/** * Sends shutdown to child instances, which run the worker(s) */ protected function shutdownWorkersFromParent() { $this->logger->info("Shutting down all workers"); // send initial signal.. foreach ($this->workers as $worker) { $name = $worker->getName(); if ($this->countRunning($name)) { /** @var Fork $fork **/ foreach ($this->forks[$name] as $fork) { $fork->kill($this->shutdownSignal); } } } // wait for shutdown $tries = $this->shutdownTimeout * 10; for ($try = $tries; $try > 0; $try--) { BuiltIn::doUsleep(100000); $resisting = 0; foreach ($this->workers as $worker) { $name = $worker->getName(); $resisting += $this->countRunning($name); } if (!$resisting) { break; } elseif ($try % 10 === 0) { $this->logger->info("{$resisting} resisting worker(s) still remaining - " . $try / 10 . " seconds till slaughter"); } } // slaughter survivors /** @var Fork[] $forks */ foreach ($this->forks as $name => $forks) { foreach ($forks as $fork) { if ($this->reallyRunning($fork)) { $this->event->dispatch(Event::EVENT_WORKER_KILL, new Event($this->workers[$name]), array($fork)); $fork->kill(SIGKILL); try { $fork->wait(true); } catch (ProcessControlException $e) { // well, it's a SIG KILL.. } } } } $this->manager->zombieOkay(true); }