PHPPM\ProcessSlave::shutdown PHP Method

shutdown() public method

Shuts down the event loop. This basically exits the process.
public shutdown ( )
    public function shutdown()
    {
        if ($this->inShutdown) {
            return;
        }
        if ($this->errorLogger && ($logs = $this->errorLogger->cleanLogs())) {
            $messages = array_map(function ($item) {
                //array($level, $message, $context);
                $message = $item[1];
                $context = $item[2];
                if (isset($context['file'])) {
                    $message .= ' in ' . $context['file'] . ':' . $context['line'];
                }
                if (isset($context['stack'])) {
                    foreach ($context['stack'] as $idx => $stack) {
                        $message .= PHP_EOL . sprintf("#%d: %s%s %s%s", $idx, isset($stack['class']) ? $stack['class'] . '->' : '', $stack['function'], isset($stack['file']) ? 'in' . $stack['file'] : '', isset($stack['line']) ? ':' . $stack['line'] : '');
                    }
                }
                return $message;
            }, $logs);
            error_log(implode(PHP_EOL, $messages));
        }
        $this->inShutdown = true;
        if ($this->loop) {
            $this->sendCurrentFiles();
            $this->loop->tick();
        }
        if ($this->controller && $this->controller->isWritable()) {
            $this->controller->close();
        }
        if ($this->server) {
            @$this->server->shutdown();
        }
        if ($this->loop) {
            $this->sendCurrentFiles();
            $this->loop->tick();
            @$this->loop->stop();
        }
        exit;
    }