From 03cf535ff6006a1bf3eb6c0169dafcedc7a32877 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sat, 8 Jul 2023 00:34:55 -0400 Subject: [PATCH] make threading optional --- core/config.py | 6 ++++++ docs/config.md | 1 + example_config/core.yaml | 1 + index.py | 5 ++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/config.py b/core/config.py index 3fb0dbe..8b85353 100644 --- a/core/config.py +++ b/core/config.py @@ -36,6 +36,12 @@ class ServerConfig: self.__config, "core", "server", "is_develop", default=True ) + @property + def threading(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "core", "server", "threading", default=False + ) + @property def log_dir(self) -> str: return CoreConfig.get_config_field( diff --git a/docs/config.md b/docs/config.md index 3e4ba8a..18f90eb 100644 --- a/docs/config.md +++ b/docs/config.md @@ -5,6 +5,7 @@ - `allow_unregistered_serials`: Allows games that do not have registered keychips to connect and authenticate. Disable to restrict who can connect to your server. Recomended to disable for production setups. Default `True` - `name`: Name for the server, used by some games in their default MOTDs. Default `ARTEMiS` - `is_develop`: Flags that the server is a development instance without a proxy standing in front of it. Setting to `False` tells the server not to listen for SSL, because the proxy should be handling all SSL-related things, among other things. Default `True` +- `threading`: Flags that `reactor.run` should be called via the `Thread` standard library. May provide a speed boost, but removes the ability to kill the server via `Ctrl + C`. Default: `False` - `log_dir`: Directory to store logs. Server MUST have read and write permissions to this directory or you will have issues. Default `logs` ## Title - `loglevel`: Logging level for the title server. Default `info` diff --git a/example_config/core.yaml b/example_config/core.yaml index 382c51b..ebf99f1 100644 --- a/example_config/core.yaml +++ b/example_config/core.yaml @@ -4,6 +4,7 @@ server: allow_unregistered_serials: True name: "ARTEMiS" is_develop: True + threading: False log_dir: "logs" title: diff --git a/index.py b/index.py index 70f4658..15d6866 100644 --- a/index.py +++ b/index.py @@ -283,4 +283,7 @@ if __name__ == "__main__": server.Site(dispatcher) ) - Thread(target=reactor.run, args=(False,)).start() + if cfg.server.threading: + Thread(target=reactor.run, args=(False,)).start() + else: + reactor.run()