Exemplo n.º 1
0
void FastCGIServer::stop() {
  if (getStatus() != RunStatus::RUNNING) return; // nothing to do

  setStatus(RunStatus::STOPPING);

  m_worker.getEventBase()->runInEventBaseThread([&] {
    // Shutdown the server socket. Unfortunately, we will drop all unaccepted
    // connections; there is no way to do a partial shutdown of a server socket
    m_socket->stopAccepting();

    if (RuntimeOption::ServerGracefulShutdownWait > 0) {
      // Gracefully drain any incomplete requests. We cannot go offline until
      // they are finished as we own their dispatcher and event base.
      if (m_acceptor) {
        m_acceptor->drainAllConnections();
      }

      std::chrono::seconds s(RuntimeOption::ServerGracefulShutdownWait);
      std::chrono::milliseconds m(s);
      scheduleTimeout(m);
    } else {
      // Drop all connections. We cannot shutdown until they stop because we
      // own their dispatcher and event base.
      if (m_acceptor) {
        m_acceptor->forceStop();
      }

      terminateServer();
    }
  });
}
Exemplo n.º 2
0
void FastCGIServer::timeoutExpired() noexcept {
  // Acceptor failed to drain connections on time; drop them so that we can
  // shutdown.
  if (m_acceptor) {
    m_acceptor->forceStop();
  }

  terminateServer();
}
Exemplo n.º 3
0
void Server::changeState(bool state)
{
    //change server running state when user toggled button
    if (state)
    {
        //start running, write data into shared memory per second via timer
        connect (timer,SIGNAL(timeout()),this,SLOT(startServer()));
        timer->start(1000);
    }
    else
    {
        //stop running
        disconnect (timer,SIGNAL(timeout()),this,SLOT(startServer()));
        timer->stop();
        terminateServer();
        label->setText("Press Start Button to start (or terminate) server.");
        dataNum = 0;
    }
}
Exemplo n.º 4
0
void FastCGIServer::onConnectionsDrained() {
  // NOTE: called from FastCGIAcceptor::onConnectionsDrained()
  cancelTimeout();
  terminateServer();
}