From 74369deaea2b66dab69157fb6edb6d7b4b956842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Garc=C3=ADa=20Amor?= Date: Mon, 3 Nov 2025 12:59:27 +0100 Subject: [PATCH] Improves arguments in mvrun.py --- mvrun.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mvrun.py b/mvrun.py index 0b9e7e4..17dfa7b 100644 --- a/mvrun.py +++ b/mvrun.py @@ -59,12 +59,9 @@ def signal_handler(sig, frame): # Run python in subprocess -def run_script(script_name, pid_file, *args): +def run_script(python_executable, script_name, pid_file, *args): process = None try: - # Path to the Python interpreter inside the virtual environment - python_executable = './env/bin/python' - # Combine the script name and arguments command = [python_executable, script_name] + list(args) @@ -101,11 +98,13 @@ def main(): # Add --config runtime argument parser.add_argument('--config', help="Path to the configuration file.", default='config.ini') + parser.add_argument('--piddir', help="PID files path.", default='.') + parser.add_argument('--pyexec', help="Path to the Python executable.", default='./env/bin/python') args = parser.parse_args() # PID file paths - db_pid_file = 'meshview-db.pid' - web_pid_file = 'meshview-web.pid' + db_pid_file = os.path.join(args.piddir, 'meshview-db.pid') + web_pid_file = os.path.join(args.piddir, 'meshview-web.pid') # Track PID files globally for cleanup pid_files.append(db_pid_file) @@ -113,12 +112,12 @@ def main(): # Database Thread dbthrd = threading.Thread( - target=run_script, args=('startdb.py', db_pid_file, '--config', args.config) + target=run_script, args=(args.pyexec, 'startdb.py', db_pid_file, '--config', args.config) ) # Web server thread webthrd = threading.Thread( - target=run_script, args=('main.py', web_pid_file, '--config', args.config) + target=run_script, args=(args.pyexec, 'main.py', web_pid_file, '--config', args.config) ) # Start Meshview subprocess threads