mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-10-31 03:01:58 +01:00
mvrun.py changes
This commit is contained in:
1 parent
83033a3a64
commit
e262c6dff8
3 files changed
+55
-8
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import argparse
|
||||
import threading
|
||||
import subprocess
|
||||
|
||||
# Run python in subprocess
|
||||
def run_script(script_name, *args):
|
||||
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)
|
||||
|
||||
# Run the subprocess and report errors
|
||||
subprocess.run(command, check=True)
|
||||
except Exception as e:
|
||||
print(f"Error running {script_name}: {e}")
|
||||
|
||||
# Parse runtime argument (--config) and start subprocess threads
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Helper script to run the datbase and web frontend in separate threads.")
|
||||
|
||||
# Add --config runtime argument
|
||||
parser.add_argument('--config', help="Path to the configuration file.", default='config.ini')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Database Thread
|
||||
dbthrd = threading.Thread(target=run_script, args=('startdb.py', '--config', args.config))
|
||||
|
||||
# Web server thread
|
||||
webthrd = threading.Thread(target=run_script, args=('main.py', '--config', args.config))
|
||||
|
||||
# Start Meshview subprocess threads
|
||||
dbthrd.start()
|
||||
webthrd.start()
|
||||
|
||||
dbthrd.join()
|
||||
webthrd.join()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user