'Setup the server.
application - an instantiated Twisted application'

def __init__(self, application):

    sys.path.insert(1, '.')
    self.services = service.MultiService()
    self.services.setServiceParent(application)
    self.amp_protocol = None
    self.sessions = SESSIONS
    self.sessions.server = self
    self.sqlite3_prep()
    self.start_time = time.time()
    self.run_initial_setup()
    channelhandler.CHANNELHANDLER.update()
    def _wrap_sigint_handler(*args):
        from twisted.internet.defer import Deferred
        if hasattr(self, 'web_root'):
            d = self.web_root.empty_threadpool()
            d.addCallback((lambda _: self.shutdown(_reactor_stopping=True)))
        else:
            d = Deferred((lambda _: self.shutdown(_reactor_stopping=True)))
        d.addCallback((lambda _: reactor.stop()))
        reactor.callLater(1, d.callback, None)
    reactor.sigInt = _wrap_sigint_handler
    self.game_running = True
    self.run_init_hooks()
