somebody won, end of the game (server restart)
180920
function(client) {
            if(client.debug >= 1)
                client.log(client.balls[client.leaders[0]] + ' WON THE GAME! Server going for restart');

            client.emitEvent('winner', client.leaders[0]);
        }
469682
def connectionLost(self, reason=protocol.connectionDone):
        
        self.connected = 0

        for pending in self._queue.values():
            pending.errback(reason)
        self._queue.clear()

        if self._stopped:
            result = self if reason.check(error.ConnectionDone) else reason
            self._stopped.callback(result)
            self._stopped = None
        else:
            reason.raiseException()
210224
def reload
            server_success = server.reload(options)
            runner_success = runner.reload(options)
            throw :task_has_failed unless server_success && runner_success
        end
205531
def restart(self, timeout=300, config_callback=None):
        """"""
        for member_id in self.server_map:
            host = self.server_map[member_id]
            server_id = self._servers.host_to_server_id(host)
            server = self._servers._storage[server_id]
            server.restart(timeout, config_callback)
        self.waiting_member_state()
210243
async def finish(self, *,
                     chat: typing.Union[str, int, None] = None,
                     user: typing.Union[str, int, None] = None):
        
        await self.reset_state(chat=chat, user=user, with_data=True)
1197958
def finish(self):
        ""
        log.debug("Session disconnected.")
        try:
            self.sock.shutdown(socket.SHUT_RDWR)
        except: pass
        self.session_end()
771674
@Override
  public PollResult startPoll(PollController conn)
  {
    if (! _lifecycle.isActive()) {
      log.warning(this + " select disabled");
        
      return PollResult.CLOSED;
    }
    else if (_selectMax <= _connectionCount.get()) {
      log.warning(this + " keepalive overflow "
                  + _connectionCount + " max=" + _selectMax);
      System.out.println("OVERFLOW:");
      
      return PollResult.CLOSED;
    }
    
    if (! conn.toKeepaliveStart()) {
      return PollResult.CLOSED;
    }

    // XXX: check for full
    _executor.execute(new PollTask(conn));
    
    return PollResult.START;
  }
438648
public void stopServer() throws Exception {
        if (!externalDatabaseHost) {
            try (Connection sqlConnection = getConnection()) {
                sqlConnection.prepareStatement("SHUTDOWN").execute();
            } catch (Exception e) {
            }

            try {
                server.stop();
            } catch (Exception e) {
            }
        }
    }
793271
def stop(self):
        """"""

        msg = ''
        if self._process:
            _stop_process(self._process, 'Server process')
        else:
            msg += 'Server not started.\n'
        if msg:
            print(msg, end='')
297478
def _local_restart_failed(self, state, fail):
        '''
        
        '''
        self.info('Restarting of %r in the same shard failed.',
                  state.descriptor.type_name)
        if self._cmp_strategy(RestartStrategy.local):
            self.info('Giving up, just sending buried notifications.')
            f = self._send_buried_notifications()
            f.add_callback(fiber.drop_param, state.medium.terminate, None)
            return f
        elif self._cmp_strategy(RestartStrategy.wherever):
            self.info('Trying to find an allocation anywhere in the cluster.')
            # first we need to clear the host partner, it is necessary, because
            # agent will bind to different exchange after the restart, so
            # he will never receive the notification
            # about burring his previous host
            f = self._clear_host_partner()
            f.add_callback(fiber.inject_param, 2,
                           state.agent.initiate_protocol,
                           start_agent.GloballyStartAgent)
            f.add_callback(fiber.call_param, 'notify_finish')
            # GloballyStartAgent task is updating descriptor, to get things
            # we need to redownload it here
            f.add_callback(fiber.bridge_param, self._fetch_descriptor)
            f.add_callbacks(self._send_restarted_notifications,
                            self._global_restart_failed)
            return f
        elif self._cmp_strategy(RestartStrategy.monitor):
            self.info('Taking over the role of the died monitor.')
            f = self._send_buried_notifications()
            f.add_callback(fiber.drop_param, self._checkup_partners)
            f.add_callback(fiber.drop_param, self._adopt_notifications)
            f.add_callback(fiber.drop_param, state.medium.terminate, None)
            return f
        else:
            state.medium.fail(RestartFailed('Unknown restart strategy: %r' %
                                            (self.factory.restart_strategy, )))
1145926
def result(self):
        
        if self._result.lower() == 'w':
            return WIN
        if self._result.lower() == 'l' and \
           self.overtime != 0:
            return OVERTIME_LOSS
        return LOSS
1055793
@Override
  public PollResult startPoll(PollController conn)
  {
    if (! _lifecycle.isActive()) {
      log.warning(this + " select disabled");
        
      return PollResult.CLOSED;
    }
    else if (_selectMax <= _connectionCount.get()) {
      log.warning(this + " keepalive overflow "
                  + _connectionCount + " max=" + _selectMax);
      System.out.println("OVERFLOW:");
      
      return PollResult.CLOSED;
    }
    
    if (! conn.toKeepaliveStart()) {
      return PollResult.CLOSED;
    }

    return poll(conn);
  }
1079799
public function result()
    {

        // Don't bother if it didn't go well
        if ($this->_res == false) {
            return false;
        }

        // Store rows here
        $rows = [];

        // Table header
        $rows[] = array(
            'type' => 'header',
            'columns' => array(
                'Name',
                'Map',
                'Time Left',
                'Gametype',
                'Players',
            ),
        );

        // Have we?
        if (count($this->_res) == 0) {
            $rows[] = array('type' => 'none', 'columns' => array(array(5, 'None found')));
        }

        // We do
        else {

            // Go through each server
            foreach ($this->_res as $server) {

                // No players? Set player column to 'none'
                if ($server['info']['num_players'] == 0) {
                    $players = 'None';
                }

                // We do; populate a mini players table
                else {

                    // Show team column?
                    $show_team = in_array($server['info']['mode'], array(
                                'Infiltration',
                                'Capture the Flag',
                                'Teammatch',
                    ));

                    // Start table
                    $players = '
					<table class="mini" style="text-align: center;">
						<tr>
							<th>Name</th>'.(
                            $show_team ? '
							<th>Team</th>' : '').'
							<th>Score</th>
							<th>Deaths</th>
							<th>Ping</th>
						</tr>';

                    // Add each player to it
                    foreach ($server['info']['players'] as $player) {
                        $players .= '
						<tr'.($show_team ?  (' style="color: '.(
                        array_key_exists($player['team'], self::$team2color) ?
                            self::$team2color[$player['team']] : 'purple'
                        ).';"') : '').'>
							<td>'.htmlspecialchars($player['name']).'</td>'.(
                            $show_team ? '
							<td>'.(array_key_exists($player['team'], self::$team2name) ?
                                self::$team2name[$player['team']] : 'None').'</td>' : '').'
							<td>'.$player['kills'].'</td>
							<td>'.$player['deaths'].'</td>
							<td>'.$player['ping'].'</td>
						</tr>';
                    }

                    // End table
                    $players .= '
					</table>
					';
                }

                // Save result in master table
                $rows[] = array(
                    'type' => 'values',
                    'columns' => array(
                        $server['name'],
                        $server['info']['map'],
                        $server['info']['timeleft'],
                        $server['info']['mode'],
                        $players,
                    ),
                );
            }
        }

        // Give info
        return array(
            'root_title' => 'Soldat Servers',
            'rows' => $rows,
        );
    }
867353
def stop(self):
        """"""
        LOG.info("Shutting down server")
        self.server.shutdown()
        LOG.debug("ServerThread.stop: Stopping ServerThread")
        self.server.server_close()
        LOG.info("Server stopped")
834252
@Override
  public synchronized void onNext(final RuntimeStop runtimeStop) {
    LOG.log(Level.FINEST, "HttpRuntimeStopHandler: {0}", runtimeStop);
    try {
      httpServer.stop();
      LOG.log(Level.FINEST, "HttpRuntimeStopHandler complete.");
    } catch (final Exception e) {
      LOG.log(Level.SEVERE, "HttpRuntimeStopHandler cannot stop the Server. {0}", e);
    }
  }
987624
@Command(name = "RestartServer")
    public void restartServer() throws DevFailed {
        xlogger.entry();
        tangoExporter.unexportAll();
        tangoExporter.exportAll();
        xlogger.exit();
    }
626219
function gracefulShutdown(){
  console.log('About to exit, closing servers.');

  servers.forEach(function(server, index){
    server.close();
  });

  process.exit();
}