Method to shut down the daemon and optionally restart it.

@param   boolean $restart True to restart the daemon on exit.

@return  void

@since   2.0
359822
protected function shutdown($restart = false)
    {
        // If we are already exiting, chill.
        if ($this->exiting) {
            return;
        } else // If not, now we are.
        {
            $this->exiting = true;
        }

        // If we aren't already daemonized then just kill the application.
        if (!$this->running && !$this->isActive()) {
            $this->getLogger()->info('Process was not daemonized yet, just halting current process');

            $this->close();
        }

        // Only read the pid for the parent file.
        if ($this->parentId == $this->processId) {
            // Read the contents of the process id file as an integer.
            $fp = fopen($this->config->get('application_pid_file'), 'r');
            $pid = fread($fp, filesize($this->config->get('application_pid_file')));
            $pid = (int) $pid;
            fclose($fp);

            // Remove the process id file.
            @ unlink($this->config->get('application_pid_file'));

            // If we are supposed to restart the daemon we need to execute the same command.
            if ($restart) {
                $this->close(exec(implode(' ', $GLOBALS['argv']) . ' > /dev/null &'));
            } else // If we are not supposed to restart the daemon let's just kill -9.
            {
                passthru('kill -9 ' . $pid);
                $this->close();
            }
        }
    }
169827
public function restart($point)
	{
		// If native FTP support is enabled let's use it...
		if (FTP_NATIVE)
		{
			if (@ftp_site($this->conn, 'REST ' . $point) === false)
			{
				Log::add(__METHOD__ . 'Bad response.', Log::WARNING, 'jerror');

				return false;
			}

			return true;
		}

		// Send restart command and verify success
		if (!$this->_putCmd('REST ' . $point, 350))
		{
			Log::add(
				sprintf(
					'%1$s: Bad response.  Server response: %2$s [Expected: 350].  Restart point sent: %3$s', __METHOD__, $this->response, $point
				),
				Log::WARNING, 'jerror'
			);

			return false;
		}

		return true;
	}
410274
public function restart()
	{
		$this->destroy();

		if ($this->state !== 'destroyed')
		{
			// @TODO :: generated error here
			return false;
		}

		// Re-register the session handler after a session has been destroyed, to avoid PHP bug
		$this->store->register();

		$this->state = 'restart';

		// Regenerate session id
		$id = $this->createId();

		session_id($id);

		$this->start();
		$this->state = 'active';

		$this->validate();
		$this->setCounter();

		return true;
	}
207506
public void shutdown(){
        synchronized(this){
            if(! isShutdown){
                if (directoryManagerFactory != null) {
                    if (directoryManagerFactory instanceof Closable) {
                        ((Closable) directoryManagerFactory).stop();
                    }
                    directoryManagerFactory = null;
                }
                if (client != null) {
                    client.close();
                    client = null;
                }
                this.isShutdown = true;
            }
        }
    }
926320
public function shutdown()
    {
        if (is_resource($this->_stream)) {
            fflush($this->_stream);
            fclose($this->_stream);
            $this->_stream = null;
        }
    }
1027482
public function shutdown($hard = false)
    {
        $error = error_get_last();
        if ($error) {
            if ($error['type'] === E_ERROR) {
                $this->log('crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
            }
        }

        if (Daemon::$config->throwexceptiononshutdown->value) {
            throw new \Exception('event shutdown');
        }

        @ob_flush();

        if ($this->terminated === true) {
            if ($hard) {
                posix_kill(getmypid(), SIGKILL);
                exit(0);
            }

            return;
        }

        $this->terminated = true;
        if ($hard) {
            posix_kill(getmypid(), SIGKILL);
            exit(0);
        }
        FileSystem::waitAllEvents(); // ensure that all I/O events completed before suicide
        posix_kill(posix_getppid(), SIGCHLD); // praying to Master
        posix_kill(getmypid(), SIGKILL);
        exit(0); // R.I.P.
    }
1343402
final public function shutdown($exception = null, $manual = false, $statusCode = 0)
    {
        $hasError = $this->handleErrors($exception);
        if ($hasError) {
            $statusCode = 1;
        }

        if (!$manual) { //if shutdown handler
            /**
             * Warning: this part will always be executed,
             * independent of the outcome of the script.
             */
            ErrorHandler::restore();
        }
        exit($statusCode);
    }
987821
public function restart($workerId = '') : void
    {
        $this->stop($workerId);
        sleep(2);
        $this->start($workerId);
    }
369643
public function restart($wait = true)
    {
        return $this->forge->restartDaemon($this->serverId, $this->id, $wait);
    }
310221
private function stop($service, $restart = false) {
        $this->output('Stopping ...', false);
        $rtn = $this->sendCommand('stop', ['service' => $service, 'restart' => $restart]);
        if ($rtn) {
            $this->output($this->getStatus($rtn['status']));
        }
    }
278905
public function reset($hard = false)
    {
        $this->files_stack              = array();
        $this->contents                 = array();
        $this->silent                   = true;
        $this->direct_output            = false;
        $this->isCleaned_files_stack    = false;
        $this->isInited                 = false;
        if (true===$hard) {
            $this->raw_header           = '';
            $this->destination_dir      = '';
            $this->web_root_path        = null;
            $this->__adapter_type       = null;
            $this->__adapter_action     = 'merge';
            $this->__adapter            = null;
        }
        $this->resetOutput();
        return $this;
    }
1022865
public function shutdown()
    {
        foreach ($this->items as $idNum => $items) {
            if (count($items) !== 0) {
                $this->flush($idNum);
            }
        }
    }
183097
public void shutdown() {
    this.shouldRun = false;
    this.namespaceSliceDUMap.clear();
    if(this.refreshUsed != null) {
      this.refreshUsed.interrupt();
      try {
        this.refreshUsed.join();
        this.refreshUsed = null;
      } catch (InterruptedException ie) {
      }
    }
  }
471898
public function abort()
    {
        if ($this->aborted) {
            return;
        }

        $this->aborted = true;
        $this->onWakeup();
        $this->onAbort();

        if ((ignore_user_abort() === 1)
            && (($this->state === Generic::STATE_RUNNING) || ($this->state === Generic::STATE_WAITING))
            && !Daemon::$compatMode
        ) {
            $this->upstream->endRequest($this);
        } else {
            $this->finish(-1);
        }

        $this->onSleep();
    }
96017
public function stop($signal = null)
    {
        if (!$this->running) {
            return;
        }

        if (null !== $signal) {
            $this->getLogger()->info('Stop called because of signal #'.$signal.'. Current state: '.$this->worker->getState().'.');
        } else {
            $this->getLogger()->info('Stop called: '.$this->worker->getState().'.');
        }

        $this->running = false;
        $this->worker->shutdown();
    }
572990
public function reset($hard = false)
    {
        $this->output = '';
        if (true===$hard) {
            $this->__adapter_type = null;
            $this->__adapter = null;
        }
        return $this;
    }
699541
public function shutdown()
    {
        // dispatch shutdown event
        $applicationEvent = $this->getApplicationEvent();
        $applicationEvent->setName(self::EVENT_SYSTEM_SHUTDOWN);
        $this->emit($applicationEvent);

        exit((int)$this->isError());
    }