From 69932c369ea7bcf62ca971b94d5be1cf1d533a6b Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 13 Oct 2018 18:50:37 +0200 Subject: [PATCH] Getting a little further in the process --- evennia/server/evennia_launcher.py | 13 ++++++++++++- evennia/server/portal/amp.py | 3 +-- evennia/server/portal/amp_server.py | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index 30ac7d7d6c..32f7a577c4 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -950,6 +950,15 @@ def reboot_evennia(pprofiler=False, sprofiler=False): send_instruction(PSTATUS, None, _portal_running, _portal_not_running) +def start_only_server(): + """ + Tell portal to start server (debug) + """ + portal_cmd, server_cmd = _get_twistd_cmdline(False, False) + print("launcher: Sending to portal: SSTART + {}".format(server_cmd)) + send_instruction(SSTART, server_cmd) + + def start_server_interactive(): """ Start the Server under control of the launcher process (foreground) @@ -2012,7 +2021,7 @@ def main(): init_game_directory(CURRENT_DIR, check_db=True) run_menu() elif option in ('status', 'info', 'start', 'istart', 'ipstart', 'reload', 'restart', 'reboot', - 'reset', 'stop', 'sstop', 'kill', 'skill'): + 'reset', 'stop', 'sstop', 'kill', 'skill', 'sstart'): # operate the server directly if not SERVER_LOGFILE: init_game_directory(CURRENT_DIR, check_db=True) @@ -2036,6 +2045,8 @@ def main(): stop_evennia() elif option == 'sstop': stop_server_only() + elif option == 'sstart': + start_only_server() elif option == 'kill': if _is_windows(): print("This option is not supported on Windows.") diff --git a/evennia/server/portal/amp.py b/evennia/server/portal/amp.py index 33bf278a17..c70528ac70 100644 --- a/evennia/server/portal/amp.py +++ b/evennia/server/portal/amp.py @@ -146,7 +146,7 @@ class Compressed(amp.String): def toString(self, inObject): """ - Convert to send as a string on the wire, with compression. + Convert to send as a bytestring on the wire, with compression. Note: In Py3 this is really a byte stream. @@ -368,7 +368,6 @@ class AMPMultiConnectionProtocol(amp.AMP): """ msg = loads(packed_data) - print("amp.data_in: {}".format(msg)) return msg def broadcast(self, command, sessid, **kwargs): diff --git a/evennia/server/portal/amp_server.py b/evennia/server/portal/amp_server.py index f8c2ff3b2b..0b8d0b2001 100644 --- a/evennia/server/portal/amp_server.py +++ b/evennia/server/portal/amp_server.py @@ -301,12 +301,15 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol): launcher. It can obviously only accessed when the Portal is already up and running. """ + # Since the launcher command uses amp.String() we need to convert from byte here. + operation = str(operation, 'utf-8') self.factory.launcher_connection = self - _, server_connected, _, _, _, _ = self.get_status() logger.log_msg("Evennia Launcher->Portal operation %s:%s received" % (ord(operation), arguments)) + logger.log_msg("operation == amp.SSTART: {}: {}".format(operation == amp.SSTART, amp.loads(arguments))) + if operation == amp.SSTART: # portal start #15 # first, check if server is already running if not server_connected: @@ -346,6 +349,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol): self.factory.portal.shutdown() else: + logger.log_msg("Operation {} not recognized".format(operation)) raise Exception("operation %(op)s not recognized." % {'op': operation}) return {}