-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_all.py
More file actions
84 lines (73 loc) · 2.66 KB
/
Copy pathstart_all.py
File metadata and controls
84 lines (73 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import subprocess
import sys
import os
import time
def main():
print("=" * 60)
print(" JARVIS QUANT SYSTEM - ONE-CLICK LAUNCHER")
print("=" * 60)
print("[INFO] Starting all services...")
processes = []
# Path to virtual env python
if os.name == 'nt':
python_bin = os.path.join("venv", "Scripts", "python.exe")
else:
python_bin = os.path.join("venv", "bin", "python")
if not os.path.exists(python_bin):
print(f"[ERROR] Virtual environment python not found at {python_bin}")
sys.exit(1)
try:
# 1. Start FastAPI backend
print("[INFO] Launching FastAPI Backend on port 8000...")
backend_proc = subprocess.Popen(
[python_bin, "-m", "uvicorn", "api.main:app", "--host", "127.0.0.1", "--port", "8000"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
processes.append(backend_proc)
time.sleep(2) # Give it time to start
# 2. Start Next.js Frontend
print("[INFO] Launching Next.js Frontend on port 3000...")
frontend_dir = os.path.abspath("frontend")
frontend_proc = subprocess.Popen(
["npm", "run", "dev"],
cwd=frontend_dir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
shell=True # Required for running npm on Windows
)
processes.append(frontend_proc)
time.sleep(2)
# 3. Start Live Trading Bot
print("[INFO] Launching JARVIS Live Trading Bot (Paper Mode)...")
# Let the bot output to the terminal directly so the user can watch it trade
bot_proc = subprocess.Popen(
[python_bin, "run_bot.py"]
)
processes.append(bot_proc)
print("=" * 60)
print(" [SUCCESS] All systems running:")
print(" - Backend API: http://127.0.0.1:8000")
print(" - Frontend UI: http://localhost:3000")
print(" - Live Bot: Actively running paper trading scan loop")
print("=" * 60)
print(" Press Ctrl+C to stop all services and exit cleanly.")
print("=" * 60)
# Keep parent process alive
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\n[INFO] Shutdown signal received. Terminating all processes...")
finally:
for proc in processes:
try:
proc.terminate()
proc.wait(timeout=3)
except Exception:
try:
proc.kill()
except Exception:
pass
print("[SUCCESS] All services terminated cleanly.")
if __name__ == "__main__":
main()