-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
105 lines (90 loc) · 3.04 KB
/
start.py
File metadata and controls
105 lines (90 loc) · 3.04 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
Simple start script for LyNexus
Uses uv run to execute Python commands
"""
import subprocess
import time
import webbrowser
from pathlib import Path
def run_cmd(command, description):
"""Run a command and wait for it to complete"""
print(f"\n{description}...")
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode != 0:
print(f"✗ Error: {result.stderr}")
return False
print("✓ Success")
return True
def main():
project_root = Path(__file__).parent
print("\n" + "="*50)
print("🚀 LyNexus - Quick Start")
print("="*50)
print(f"📂 Project: {project_root}")
print("="*50)
try:
# Install dependencies
print("\n[1/3] Installing dependencies...")
if not run_cmd(
"uv pip install fastapi uvicorn[standard] sse-starlette pydantic python-multipart httpx requests aiofiles python-dotenv",
"Installing Python packages (this may take a few minutes)"
):
return
# Start API server in background
print("\n[2/3] Starting API server...")
api_process = subprocess.Popen(
"uv run uvicorn api_server:app --host 127.0.0.1 --port 8000 --reload",
cwd=project_root,
shell=True
)
# Wait for API server to start
print(" Waiting for server to start...")
time.sleep(5)
print("✓ API server running at http://127.0.0.1:8000")
# Start WebUI in background
print("\n[3/3] Starting WebUI...")
webui_dir = project_root / "webui"
if webui_dir.exists():
web_process = subprocess.Popen(
"npm run dev",
cwd=webui_dir,
shell=True
)
print("✓ WebUI running at http://localhost:5173")
else:
print("✗ WebUI directory not found")
print(" Run: cd webui && npm install && npm run dev")
api_process.terminate()
return
print("\n" + "="*50)
print("✓ All services started!")
print("="*50)
print("\n🌐 Opening browser...")
webbrowser.open("http://localhost:5173")
print("\n💡 Press Ctrl+C to stop all services")
print("="*50 + "\n")
# Wait for user to stop
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\n\n" + "="*50)
print("🛑 Stopping all services...")
print("="*50 + "\n")
api_process.terminate()
if 'web_process' in locals():
web_process.terminate()
api_process.wait()
if 'web_process' in locals():
web_process.wait()
print("✓ All services stopped. Goodbye!\n")
except Exception as e:
print(f"\n✗ Error: {e}")
# Cleanup
try:
if 'api_process' in locals():
api_process.terminate()
except:
pass
if __name__ == "__main__":
main()