From 74d36a9eefa14fdbcc44e3fa8cecc5bf8a28f4f0 Mon Sep 17 00:00:00 2001 From: tslcls Date: Fri, 17 Jan 2025 11:03:15 +0900 Subject: [PATCH 1/2] fix: start server script --- core/morph/task/server.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/morph/task/server.py b/core/morph/task/server.py index 29c6e9c..44fd7fa 100644 --- a/core/morph/task/server.py +++ b/core/morph/task/server.py @@ -22,13 +22,24 @@ def emit(self, record): def parse_sys_argv(): port = 8080 - args = sys.argv[1:] - for i in range(len(args)): - if args[i] == "--port" and i + 1 < len(args): + filtered_args = [] + skip_next = False + for i, arg in enumerate(sys.argv[1:]): + if skip_next: + skip_next = False + continue + + if arg == "--port" and i + 1 < len(sys.argv): try: - port = int(args[i + 1]) + port = int(sys.argv[i + 2]) + skip_next = True except ValueError: port = 8080 + continue + + filtered_args.append(arg) + + sys.argv = [sys.argv[0]] + filtered_args return port From 3055531cf9545333ca832391dd88c9efe6f92399 Mon Sep 17 00:00:00 2001 From: tslcls Date: Fri, 17 Jan 2025 11:03:15 +0900 Subject: [PATCH 2/2] fix: start server script --- core/morph/task/server.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/morph/task/server.py b/core/morph/task/server.py index 29c6e9c..44fd7fa 100644 --- a/core/morph/task/server.py +++ b/core/morph/task/server.py @@ -22,13 +22,24 @@ def emit(self, record): def parse_sys_argv(): port = 8080 - args = sys.argv[1:] - for i in range(len(args)): - if args[i] == "--port" and i + 1 < len(args): + filtered_args = [] + skip_next = False + for i, arg in enumerate(sys.argv[1:]): + if skip_next: + skip_next = False + continue + + if arg == "--port" and i + 1 < len(sys.argv): try: - port = int(args[i + 1]) + port = int(sys.argv[i + 2]) + skip_next = True except ValueError: port = 8080 + continue + + filtered_args.append(arg) + + sys.argv = [sys.argv[0]] + filtered_args return port