Start the server.

@return \Amp\Promise
320292
public function start(): Promise
    {
        try {
            if ($this->state === self::STOPPED) {
                return new Coroutine($this->doStart());
            }

            return new Failure(new \Error(
                "Cannot start server: already " . self::STATES[$this->state]
            ));
        } catch (\Throwable $uncaught) {
            return new Failure($uncaught);
        }
    }
1231931
public function run()
    {
        if (!$this->started) {
            $this->start();
        }

        if (function_exists('pcntl_signal')) {
            // PHP 7.1 allows async signals
            if (function_exists('pcntl_async_signals')) {
                pcntl_async_signals(true);
            } else {
                declare(ticks = 1);
            }
            pcntl_signal(SIGTERM, array($this, 'shutdown'));
            pcntl_signal(SIGINT, array($this, 'shutdown'));
            pcntl_signal(SIGQUIT, array($this, 'shutdown'));
        }

        register_shutdown_function(array($this, 'close'));

        while (true) {
            if ($this->shutdown) {
                $this->log('Shutting down listener on <pop>'.$this.'</pop>', Logger::INFO);
                break;
            }

            $read = array($this->socket);
            foreach ($this->clients as &$client) {
                $read[] = $client->getSocket();
            }

            // Set up a blocking call to socket_select
            $write = $except = null;
            if (($changed_sockets = @socket_select($read, $write, $except, $this->tv_sec)) < 1) {
                // $this->log('Waiting for socket update', self::LOG_VERBOSE);
                continue;
            }

            // Handle new Connections
            if (in_array($this->socket, $read)) {
                if (count($this->clients) >= $this->max_clients) {
                    $this->log('New client trying to connect but maximum <pop>'.$this->max_clients.'</pop> clients already connected', Logger::INFO);

                    $client = new Client($this->socket);
                    $this->send($client, '{"ok":0,"message":"Could not connect, hit max number of connections"}');
                    $client->disconnect();
                    continue;
                } else {
                    $this->clients[] = $client = new Client($this->socket);

                    $this->log('New client connected: <pop>'.$client.'</pop>', Logger::INFO);

                    $this->fire(self::CLIENT_CONNECT, $client);
                }
            }

            // Handle input for each client
            foreach ($this->clients as $i => $client) {
                if (in_array($client->getSocket(), $read)) {
                    $data = @socket_read($client->getSocket(), $this->max_read);

                    if ($data === false) {
                        $this->disconnect($client);
                        continue;
                    }

                    // Remove any control characters
                    $data = preg_replace('/[\x00-\x1F\x7F]/', '', trim($data));

                    if (empty($data)) {
                        // Send a null byte to flush
                        $this->send($client, "\0");
                    } else {
                        $this->log(sprintf('Received "<comment>%s</comment>" from <pop>%s</pop>', $data, $client), Logger::INFO);
                        $this->fire(self::CLIENT_RECEIVE, $client, $data);
                    }
                }
            }
        }
    }
1117974
public function serve() {

        $this->logger->notice("Start serving request");

        $parameters_object = new Parameters($this->capabilities, $this->methods, $this->errors, $this->logger, $this->protocol);

        try {

            $this->logger->debug("Received payload: ".$this->payload);

            $payload = $this->uncan($this->payload);

            $this->logger->debug("Decoded payload", (array) $payload);

            if ( $this->protocol == self::XMLRPC ) $result = XmlProcessor::process($payload, $parameters_object, $this->logger);

            else if ( $this->protocol == self::JSONRPC ) $result = JsonProcessor::process($payload, $parameters_object, $this->logger);

            else throw new Exception('Invalid or unsupported RPC protocol');

        } catch (RpcException $re) {

            return $this->can($re, true);

        } catch (Exception $e) {

            throw $e;

        }

        return $this->can($result, false);

    }
711672
public function launch()
    {
        // Normalize sets setting to an array:
        $sets = (array)$this->set;
        if (empty($sets)) {
            $sets = [null];
        }

        // Load last state, if applicable (used to recover from server failure).
        if ($state = $this->stateManager->loadState()) {
            $this->write("Found saved state; attempting to resume.\n");
            list($resumeSet, $resumeToken, $this->startDate) = $state;
        }

        // Loop through all of the selected sets:
        foreach ($sets as $set) {
            // If we're resuming and there are multiple sets, find the right one.
            if (isset($resumeToken) && $resumeSet != $set) {
                continue;
            }

            // If we have a token to resume from, pick up there now...
            if (isset($resumeToken)) {
                $token = $resumeToken;
                unset($resumeToken);
            } else {
                // ...otherwise, start harvesting at the requested date:
                $token = $this->getRecordsByDate(
                    $this->startDate, $set, $this->harvestEndDate
                );
            }

            // Keep harvesting as long as a resumption token is provided:
            while ($token !== false) {
                // Save current state in case we need to resume later:
                $this->stateManager->saveState($set, $token, $this->startDate);
                $token = $this->getRecordsByToken($token);
            }
        }

        // If we made it this far, all was successful, so we should clean up
        // the stored state.
        $this->stateManager->clearState();
    }
1178448
public function start()
    {
        if (!$this->isStarted()) {
            if ($this->cookie
                && !empty($_COOKIE[session_name()])
            ) {
                session_id($_COOKIE[session_name()]);
            }

            session_start();
        }

        return $this;
    }
379805
public function start()
  {
    try
    {
        $host    = $this->getOption('host');
        $port    = intval($this->getOption('port'));
        $binary  = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
        $docroot = ProcessUtils::escapeArgument($this->getOption('docroot'));
        $output  = $this->output;

        $this->writeln([
          sprintf('Codeigniter development server started at %s', date(DATE_RFC2822)),
          sprintf('Listening on http://%s:%s', $host, $port),
          sprintf('Document root is %s', getcwd()),
          'Press Ctrl-C to quit.'
        ]);

        $process = new Process(sprintf('%s -S %s:%s -t %s', $binary, $host, $port, $docroot));

        $process
            // ->setWorkingDirectory(getcwd())
            ->setTimeout(0)
            ->setPTY(true)
            ->run(function ($type, $buffer) use($output) {
                if (Process::ERR === $type && $output instanceof ConsoleOutputInterface) {
                    $output = $output->getErrorOutput();
                }
                $output->write($buffer, false, OutputInterface::OUTPUT_RAW);
            });
    }
    catch (Exception $e)
    {
        $this->error(sprintf(
            'Error starting the server: %s', $e->getMessage()
        ));
    }
  }
1210171
public function start()
    {
        if ($this->started) {
            return;
        }

        $auth = $this->getAuthFlag();

        $command = 'transmission-remote -C ' . $auth
            . ' -' . ($this->encryption ? 'er' : 'ep')
            . ' -p ' . $this->port
            . ' -' . ($this->upnp ? 'm' : 'M')
            . ($this->downloadPath ? ' -w ' . $this->downloadPath : '');
        $this->execute($command);

        $this->execute('transmission-remote ' . $auth . ' -l');
        if ($this->getStatus() == 1) {
            $this->execute('transmission-daemon');
        }

        $this->started = true;
    }
240465
protected function start()
    {
        $this->processes[] = $this->createProcess()->handleOutputUsing(function ($type, $line) {
            call_user_func($this->output, $type, $line);
        });

        return $this;
    }
420642
public function start()
    {

        // we need the session to be started
        if ($this->isStarted()) {
            return;
        }

        // create a new cookie with the session values
        $cookie = new HttpCookie(
            $this->getName(),
            $this->getId(),
            $this->getLifetime(),
            $this->getMaximumAge(),
            $this->getDomain(),
            $this->getPath(),
            $this->isSecure(),
            $this->isHttpOnly()
        );

        // start the session and set the started flag
        $this->getSession()->start();

        // add the cookie to the response
        $this->getRequest()->setRequestedSessionId($this->getId());
        $this->getResponse()->addCookie($cookie);
    }
837163
async def start(self):
        """"""

        await self.server.start()
        self.port = self.server.port
888900
function launch(){

        $this->waitAnswer();
        $template = $this->getHomeCard();
        $server = self::$servers[array_rand(self::$servers)];
        $speech = '欢迎使用平台样例演示，请试着说' . $server;
        $reprompt = '没有听懂，可以直接对我想要使用的服务，例如' . $server;
        $hint = new Hint($server);

        return [
            'outputSpeech' => $speech,
            'reprompt' => $reprompt,
            'directives' => [$hint, $template]
        ];
    }
1042305
public function startCheck()
    {
        $masterPool = getInstance()->getAsynPool($this->master);
        if (!$masterPool) {
            $masterPool = new MysqlAsynPool(getInstance()->config, $this->master);
            getInstance()->addAsynPool($this->master, $masterPool, true);
        }

        foreach ($this->slaves as $slavePoolName) {
            $slavePool = getInstance()->getAsynPool($slavePoolName);
            if (!$slavePool) {
                $slavePool = new MysqlAsynPool(getInstance()->config, $slavePoolName);
                getInstance()->addAsynPool($slavePoolName, $slavePool, true);
            }
        }

        return $this;
    }
1187428
public function startCommand(): void
    {
        $daemon = $this->getSameOpt(['d', 'daemon']);

        $this->createServer()->asDaemon($daemon)->start();
    }
199931
public function start()
    {
        foreach ($this->callbacks as $event => $callback) {
            $this->client->on($event, $callback);
        }
        $this->connect();
    }
561617
public function start()
    {
        $this->brokerModel->consume(
            $this->pushSettings->getInputQueue(),
            function (\AMQPEnvelope $envelope, \AMQPQueue $queue) {
                return $this->messageProcessor->process(
                    $envelope,
                    $queue,
                    $this->pushPipe,
                    $this->pushSettings->getErrorQueue(),
                    new ReceiveCancellationToken(),
                    new EndpointControlToken()
                );
            }
        );
    }
44903
public function run()
    {

        // register a shutdown handler for controlled shutdown
        register_shutdown_function(array(&$this, 'shutdown'));

        // we need the autloader again
        require SERVER_AUTOLOADER;

        // create the service emitter
        $emitter = new Emitter();

        // load the bootstrap configuration
        /** @var \AppserverIo\Appserver\Core\Api\Node\BootstrapNodeInterface $bootstrapNode */
        $bootstrapNode = $this->doLoadBootstrap($this->getBootstrapConfigurationFilename());

        // iterate over the listeners and add them to the emitter
        /** @var \AppserverIo\Appserver\Core\Api\Node\ListenerNodeInterface $listener */
        foreach ($bootstrapNode->getListeners() as $listener) {
            // load the listener class name
            $listenerClassName = $listener->getType();

            // create a new instance of the listener class
            /** @var \League\Event\ListenerInterface $listenerInstance */
            $listenerInstance = new $listenerClassName();

            // query whether we've to inject the application server instance or not
            if ($listenerInstance instanceof ApplicationServerAwareListenerInterface) {
                $listenerInstance->injectApplicationServer($this);
            }

            // add the listeners
            $emitter->addListener($listener->getEvent(), $listenerInstance);
        }

        // synchronize the emitter
        $this->emitter = $emitter;

        // override the default runlevel with the value found in the bootstrap configuration
        $this->runlevel = $this->runlevelFromString($bootstrapNode->getDefaultRunlevel());

        // flag to keep the server running or to stop it
        $keepRunning = true;

        // initialize the actual runlevel with -1
        $actualRunlevel = -1;

        // start with the default runlevel
        $this->init(null, $this->runlevel);

        do {
            try {
                switch ($this->command) {
                    case InitCommand::COMMAND:
                        // copy command params -> the requested runlevel in that case
                        $this->runlevel = $this->params;

                        if ($this->runlevel == ApplicationServerInterface::REBOOT) {
                            // backup the runlevel
                            $backupRunlevel = $actualRunlevel;

                            // shutdown the application server
                            for ($i = $actualRunlevel; $i >= ApplicationServerInterface::SHUTDOWN; $i--) {
                                $this->emitter->emit(sprintf('leave.runlevel.%s', $this->runlevelToString($i)), $i);
                                // stop the services of the PREVIOUS runlevel
                                $this->doStopServices($i + 1);
                            }

                            // switch back to the runlevel we backed up before
                            for ($z = ApplicationServerInterface::SHUTDOWN; $z <= $backupRunlevel; $z++) {
                                $this->emitter->emit(sprintf('enter.runlevel.%s', $this->runlevelToString($z)), $z);
                            }

                            // set the runlevel to the one before we restart
                            $actualRunlevel = $backupRunlevel;

                            // reset the runlevel and the params
                            $this->runlevel = $this->params = $actualRunlevel;

                        } elseif ($actualRunlevel == ApplicationServerInterface::SHUTDOWN) {
                            // we want to shutdown the application server
                            $keepRunning = false;

                        } elseif ($actualRunlevel < $this->runlevel) {
                            // switch to the requested runlevel
                            for ($i = $actualRunlevel + 1; $i <= $this->runlevel; $i++) {
                                $this->emitter->emit(sprintf('enter.runlevel.%s', $this->runlevelToString($i)), $i);
                            }

                            // set the new runlevel
                            $actualRunlevel = $this->runlevel;

                        } elseif ($actualRunlevel > $this->runlevel) {
                            // switch down to the requested runlevel
                            for ($i = $actualRunlevel; $i >= $this->runlevel; $i--) {
                                $this->emitter->emit(sprintf('leave.runlevel.%s', $this->runlevelToString($i)), $i);
                                // stop the services of the PREVIOUS runlevel
                                $this->doStopServices($i + 1);
                            }

                            // set the new runlevel
                            $actualRunlevel = $this->runlevel;

                        } else {
                            // signal that we've finished switching the runlevels and wait
                            $this->locked = false;
                            $this->command = null;

                            // print a message and wait
                            $this->getSystemLogger()->info(sprintf('Switched to runlevel %s!!!', $actualRunlevel));

                            // wait for a new command
                            $this->synchronized(function ($self) {
                                $self->wait();
                            }, $this);
                        }

                        break;

                    case ModeCommand::COMMAND:

                        // switch the application server mode
                        $this->doSwitchSetupMode($this->params, $this->getConfigurationFilename());

                        // singal that we've finished setting umask and wait
                        $this->locked = false;
                        $this->command = null;

                        // wait for a new command
                        $this->synchronized(function ($self) {
                            $self->wait();
                        }, $this);

                        break;

                    default:

                        // print a message and wait
                         $this->getSystemLogger()->info('Can\'t find any command!!!');

                        // singal that we've finished setting umask and wait
                        $this->locked = false;

                        // wait for a new command
                        $this->synchronized(function ($self) {
                            $self->wait();
                        }, $this);

                        break;
                }

            } catch (\Exception $e) {
                $this->getSystemLogger()->error($e->getMessage());
            }

        } while ($keepRunning);
    }
1062308
public function start() {

        // indicate the library that it should execute queued requests
        $this->_queue = false;

        // if we have to pause between batches of requests, process them sequentially, in batches
        if ($this->pause_interval > 0) $this->_process_paused();

        // if we don't have to pause between batches of requests, process them all at once
        else $this->_process();

    }