# evennia.server.server

This module implements the main Evennia server process, the core of the game engine.

This module should be started with the ‘twistd’ executable since it sets up all the networking features. (this is done automatically by evennia/server/server_runner.py).

class `evennia.server.server.``Evennia`(application)

  Bases: `object`

  The main Evennia server handler. This object sets up the database and tracks and interlinks all the twisted network services that make up evennia.

  `__init__`(application)

    Setup the server.

    application - an instantiated Twisted application

  `sqlite3_prep`()

    Optimize some SQLite stuff at startup since we can’t save it to the database.

  `update_defaults`()

    We make sure to store the most important object defaults here, so we can catch if they change and update them on-objects automatically. This allows for changing default cmdset locations and default typeclasses in the settings file and have them auto-update all already existing objects.

  `run_initial_setup`()

    This is triggered by the amp protocol when the connection to the portal has been established. This attempts to run the initial_setup script of the server. It returns if this is not the first time the server starts. Once finished the last_initial_setup_step is set to ‘done’

  `create_default_channels`()

    check so default channels exist on every restart, create if not.

  `run_init_hooks`(mode)

    Called by the amp client once receiving sync back from Portal

    Parameters

      mode (str) – One of shutdown, reload or reset

  `shutdown`(mode='reload', _reactor_stopping=False)

    Shuts down the server from inside it.

    mode - sets the server restart mode.

      - ‘reload’ - server restarts, no “persistent” scripts are stopped, at_reload hooks called.

      - ‘reset’ - server restarts, non-persistent scripts stopped, at_shutdown hooks called but sessions will not be disconnected.

      - ‘shutdown’ - like reset, but server will not auto-restart.

    _reactor_stopping - this is set if server is stopped by a kill

      command OR this method was already called once - in both cases the reactor is dead/stopping already.

  `get_info_dict`()

    Return the server info, for display.

  `at_server_init`()

    This is called first when the server is starting, before any other hooks, regardless of how it’s starting.

  `at_server_start`()

    This is called every time the server starts up, regardless of how it was shut down.

  `at_server_stop`()

    This is called just before a server is shut down, regardless of it is fore a reload, reset or shutdown.

  `at_server_reload_start`()

    This is called only when server starts back up after a reload.

  `at_post_portal_sync`(mode)

    This is called just after the portal has finished syncing back data to the server after reconnecting.

    Parameters

      mode (str) – One of ‘reload’, ‘reset’ or ‘shutdown’.

  `at_server_reload_stop`()

    This is called only time the server stops before a reload.

  `at_server_cold_start`()

    This is called only when the server starts “cold”, i.e. after a shutdown or a reset.

  `at_server_cold_stop`()

    This is called only when the server goes down due to a shutdown or reset.