public function start(Console $console) : \Generator
{
try {
if ($this->state) {
throw new \LogicException("A process may only be started once");
}
$this->registerSignalHandler();
$this->registerShutdownHandler();
$this->registerErrorHandler();
$this->state = self::STARTED;
yield from $this->doStart($console);
// Once we make it this far we no longer want to terminate
// the process in the event of an uncaught exception inside
// the event reactor -- log it instead.
\Amp\onError([$this->logger, "critical"]);
} catch (\Throwable $uncaught) {
$this->exitCode = 1;
$this->logger->critical($uncaught);
static::exit();
}
}