evennia.server.evennia_launcher

Evennia launcher program

This is the start point for running Evennia.

Sets the appropriate environmental variables for managing an Evennia game. It will start and connect to the Portal, through which the Server is also controlled. This pprogram

Run the script with the -h flag to see usage information.

class evennia.server.evennia_launcher.MsgStatus(**kw)[源代码]

基类:twisted.protocols.amp.Command

Ping between AMP services

key = 'MsgStatus'
arguments: List[Tuple[bytes, twisted.protocols.amp.Argument]] = [(b'status', <twisted.protocols.amp.String object>)]
errors: Dict[Type[Exception], bytes] = {<class 'Exception'>: b'EXCEPTION'}
response: List[Tuple[bytes, twisted.protocols.amp.Argument]] = [(b'status', <twisted.protocols.amp.String object>)]
allErrors = {<class 'Exception'>: b'EXCEPTION'}
commandName = b'MsgStatus'
reverseErrors = {b'EXCEPTION': <class 'Exception'>}
class evennia.server.evennia_launcher.MsgLauncher2Portal(**kw)[源代码]

基类:twisted.protocols.amp.Command

Message Launcher -> Portal

key = 'MsgLauncher2Portal'
arguments: List[Tuple[bytes, twisted.protocols.amp.Argument]] = [(b'operation', <twisted.protocols.amp.String object>), (b'arguments', <twisted.protocols.amp.String object>)]
errors: Dict[Type[Exception], bytes] = {<class 'Exception'>: b'EXCEPTION'}
response: List[Tuple[bytes, twisted.protocols.amp.Argument]] = []
allErrors = {<class 'Exception'>: b'EXCEPTION'}
commandName = b'MsgLauncher2Portal'
reverseErrors = {b'EXCEPTION': <class 'Exception'>}
class evennia.server.evennia_launcher.AMPLauncherProtocol[源代码]

基类:twisted.protocols.amp.AMP

Defines callbacks to the launcher

__init__()[源代码]

Initialize self. See help(type(self)) for accurate signature.

wait_for_status(callback)[源代码]

Register a waiter for a status return.

receive_status_from_portal(status)[源代码]

Get a status signal from portal - fire next queued callback

evennia.server.evennia_launcher.send_instruction(operation, arguments, callback=None, errback=None)[源代码]

Send instruction and handle the response.

evennia.server.evennia_launcher.query_status(callback=None)[源代码]

Send status ping to portal

evennia.server.evennia_launcher.wait_for_status_reply(callback)[源代码]

Wait for an explicit STATUS signal to be sent back from Evennia.

evennia.server.evennia_launcher.wait_for_status(portal_running=True, server_running=True, callback=None, errback=None, rate=0.5, retries=20)[源代码]

Repeat the status ping until the desired state combination is achieved.

参数
  • portal_running (bool or None) – Desired portal run-state. If None, any state is accepted.

  • server_running (bool or None) – Desired server run-state. If None, any state is accepted. The portal must be running.

  • callback (callable) – Will be called with portal_state, server_state when condition is fulfilled.

  • errback (callable) – Will be called with portal_state, server_state if the request is timed out.

  • rate (float) – How often to retry.

  • retries (int) – How many times to retry before timing out and calling errback.

evennia.server.evennia_launcher.collectstatic()[源代码]

Run the collectstatic django command

evennia.server.evennia_launcher.start_evennia(pprofiler=False, sprofiler=False)[源代码]

This will start Evennia anew by launching the Evennia Portal (which in turn will start the Server)

evennia.server.evennia_launcher.reload_evennia(sprofiler=False, reset=False)[源代码]

This will instruct the Portal to reboot the Server component. We do this manually by telling the server to shutdown (in reload mode) and wait for the portal to report back, at which point we start the server again. This way we control the process exactly.

evennia.server.evennia_launcher.stop_evennia()[源代码]

This instructs the Portal to stop the Server and then itself.

evennia.server.evennia_launcher.reboot_evennia(pprofiler=False, sprofiler=False)[源代码]

This is essentially an evennia stop && evennia start except we make sure the system has successfully shut down before starting it again.

If evennia was not running, start it.

evennia.server.evennia_launcher.start_only_server()[源代码]

Tell portal to start server (debug)

evennia.server.evennia_launcher.start_server_interactive()[源代码]

Start the Server under control of the launcher process (foreground)

evennia.server.evennia_launcher.start_portal_interactive()[源代码]

Start the Portal under control of the launcher process (foreground)

提示

In a normal start, the launcher waits for the Portal to start, then tells it to start the Server. Since we can’t do this here, we instead start the Server first and then starts the Portal - the Server will auto-reconnect to the Portal. To allow the Server to be reloaded, this relies on a fixed server server-cmdline stored as a fallback on the portal application in evennia/server/portal/portal.py.

evennia.server.evennia_launcher.stop_server_only(when_stopped=None, interactive=False)[源代码]

Only stop the Server-component of Evennia (this is not useful except for debug)

参数
  • when_stopped (callable) – This will be called with no arguments when Server has stopped (or if it had already stopped when this is called).

  • interactive (bool, optional) – Set if this is called as part of the interactive reload mechanism.

evennia.server.evennia_launcher.query_info()[源代码]

Display the info strings from the running Evennia

evennia.server.evennia_launcher.tail_log_files(filename1, filename2, start_lines1=20, start_lines2=20, rate=1)[源代码]

Tail two logfiles interactively, combining their output to stdout

When first starting, this will display the tail of the log files. After that it will poll the log files repeatedly and display changes.

参数
  • filename1 (str) – Path to first log file.

  • filename2 (str) – Path to second log file.

  • start_lines1 (int) – How many lines to show from existing first log.

  • start_lines2 (int) – How many lines to show from existing second log.

  • rate (int, optional) – How often to poll the log file.

evennia.server.evennia_launcher.evennia_version()[源代码]

Get the Evennia version info from the main package.

evennia.server.evennia_launcher.check_main_evennia_dependencies()[源代码]

Checks and imports the Evennia dependencies. This must be done already before the paths are set up.

返回

not_error (bool) – True if no dependency error was found.

evennia.server.evennia_launcher.set_gamedir(path)[源代码]

Set GAMEDIR based on path, by figuring out where the setting file is inside the directory tree. This allows for running the launcher from elsewhere than the top of the gamedir folder.

evennia.server.evennia_launcher.create_secret_key()[源代码]

Randomly create the secret key for the settings file

evennia.server.evennia_launcher.create_settings_file(init=True, secret_settings=False)[源代码]

Uses the template settings file to build a working settings file.

参数
  • init (bool) – This is part of the normal evennia –init operation. If false, this function will copy a fresh template file in (asking if it already exists).

  • secret_settings (bool, optional) – If False, create settings.py, otherwise create the secret_settings.py file.

evennia.server.evennia_launcher.create_game_directory(dirname)[源代码]

Initialize a new game directory named dirname at the current path. This means copying the template directory from evennia’s root.

参数

dirname (str) – The directory name to create.

evennia.server.evennia_launcher.create_superuser()[源代码]

Create the superuser account

evennia.server.evennia_launcher.check_database(always_return=False)[源代码]

Check so the database exists.

参数

always_return (bool, optional) – If set, will always return True/False also on critical errors. No output will be printed.

返回

exists (bool)True if the database exists, otherwise False.

evennia.server.evennia_launcher.getenv()[源代码]

Get current environment and add PYTHONPATH.

返回

env (dict) – Environment global dict.

evennia.server.evennia_launcher.get_pid(pidfile, default=None)[源代码]

Get the PID (Process ID) by trying to access an PID file.

参数
  • pidfile (str) – The path of the pid file.

  • default (int, optional) – What to return if file does not exist.

返回

pid (str) – The process id or default.

evennia.server.evennia_launcher.del_pid(pidfile)[源代码]

The pidfile should normally be removed after a process has finished, but when sending certain signals they remain, so we need to clean them manually.

参数

pidfile (str) – The path of the pid file.

evennia.server.evennia_launcher.kill(pidfile, component='Server', callback=None, errback=None, killsignal=<Signals.SIGINT: 2>)[源代码]

Send a kill signal to a process based on PID. A customized success/error message will be returned. If clean=True, the system will attempt to manually remove the pid file. On Windows, no arguments are useful since Windows has no ability to direct signals except to all children of a console.

参数
  • pidfile (str) – The path of the pidfile to get the PID from. This is ignored on Windows.

  • component (str, optional) – Usually one of ‘Server’ or ‘Portal’. This is ignored on Windows.

  • errback (callable, optional) – Called if signal failed to send. This is ignored on Windows.

  • callback (callable, optional) – Called if kill signal was sent successfully. This is ignored on Windows.

  • killsignal (int, optional) – Signal identifier for signal to send. This is ignored on Windows.

evennia.server.evennia_launcher.show_version_info(about=False)[源代码]

Display version info.

参数

about (bool) – Include ABOUT info as well as version numbers.

返回

version_info (str) – A complete version info string.

evennia.server.evennia_launcher.error_check_python_modules(show_warnings=False)[源代码]

Import settings modules in settings. This will raise exceptions on pure python-syntax issues which are hard to catch gracefully with exceptions in the engine (since they are formatting errors in the python source files themselves). Best they fail already here before we get any further.

关键字参数

show_warnings (bool) – If non-fatal warning messages should be shown.

evennia.server.evennia_launcher.init_game_directory(path, check_db=True, need_gamedir=True)[源代码]

Try to analyze the given path to find settings.py - this defines the game directory and also sets PYTHONPATH as well as the django path.

参数
  • path (str) – Path to new game directory, including its name.

  • check_db (bool, optional) – Check if the databae exists.

  • need_gamedir (bool, optional) – set to False if Evennia doesn’t require to be run in a valid game directory.

evennia.server.evennia_launcher.run_dummyrunner(number_of_dummies)[源代码]

Start an instance of the dummyrunner

参数

number_of_dummies (int) – The number of dummy accounts to start.

提示

The dummy accounts’ behavior can be customized by adding a dummyrunner_settings.py config file in the game’s conf/ directory.

evennia.server.evennia_launcher.run_connect_wizard()[源代码]

Run the linking wizard, for adding new external connections.

evennia.server.evennia_launcher.list_settings(keys)[源代码]

Display the server settings. We only display the Evennia specific settings here. The result will be printed to the terminal.

参数

keys (str or list) – Setting key or keys to inspect.

evennia.server.evennia_launcher.run_custom_commands(option, *args)[源代码]

Inject a custom option into the evennia launcher command chain.

参数
  • option (str) – Incoming option - the first argument after evennia on the command line.

  • *args – All args will passed to a found callable.__dict__

返回

bool – If a custom command was found and handled the option.

提示

Provide new commands in settings with

CUSTOM_EVENNIA_LAUNCHER_COMMANDS = {“mycmd”: “path.to.callable”, …}

The callable will be passed any *args given on the command line and is expected to handle/validate the input correctly. Use like any other evennia command option on in the terminal/console, for example:

evennia mycmd foo bar

evennia.server.evennia_launcher.run_menu()[源代码]

This launches an interactive menu.

evennia.server.evennia_launcher.main()[源代码]

Run the evennia launcher main program.