From 317f47075c03aa2203790771d1299f5bb2d9595f Mon Sep 17 00:00:00 2001 From: Jonathan Wang Date: Fri, 25 Apr 2025 14:28:01 +0800 Subject: [PATCH 1/2] chore: enable verbose log output when router start --- src/mcpm/commands/router.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mcpm/commands/router.py b/src/mcpm/commands/router.py index cf2c16a9..0c5af324 100644 --- a/src/mcpm/commands/router.py +++ b/src/mcpm/commands/router.py @@ -86,7 +86,8 @@ def router(): @router.command(name="on") @click.help_option("-h", "--help") -def start_router(): +@click.option("--verbose", "-v", is_flag=True, help="Enable verbose output") +def start_router(verbose): """Start MCPRouter as a daemon process. Example: @@ -128,6 +129,7 @@ def start_router(): # open log file, prepare to redirect stdout and stderr with open(log_file, "a") as log: # use subprocess.Popen to start uvicorn + start = log.tell() process = subprocess.Popen( uvicorn_cmd, stdout=log, @@ -135,6 +137,17 @@ def start_router(): env=os.environ.copy(), start_new_session=True, # create new session, so the process won't be affected by terminal closing ) + if verbose: + with open(log_file, "r") as log: + # print log before startup complete + log.seek(start) + while True: + line = log.readline() + if not line: + continue + console.print(line.strip()) + if "Application startup complete." in line: + break # record PID pid = process.pid From 2223f8f2f19fd7c0e51749506cb11305e608a0c6 Mon Sep 17 00:00:00 2001 From: Jonathan Wang Date: Fri, 25 Apr 2025 14:33:29 +0800 Subject: [PATCH 2/2] chore: add separator --- src/mcpm/commands/router.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mcpm/commands/router.py b/src/mcpm/commands/router.py index 0c5af324..641583ba 100644 --- a/src/mcpm/commands/router.py +++ b/src/mcpm/commands/router.py @@ -138,6 +138,7 @@ def start_router(verbose): start_new_session=True, # create new session, so the process won't be affected by terminal closing ) if verbose: + console.rule("verbose log start") with open(log_file, "r") as log: # print log before startup complete log.seek(start) @@ -148,6 +149,7 @@ def start_router(verbose): console.print(line.strip()) if "Application startup complete." in line: break + console.rule("verbose log end") # record PID pid = process.pid