-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_evoldsl.py
More file actions
executable file
Β·187 lines (154 loc) Β· 5.88 KB
/
Copy pathstart_evoldsl.py
File metadata and controls
executable file
Β·187 lines (154 loc) Β· 5.88 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/env python3
"""
Startup script for EvolDSL Professional Frontend
Starts both the backend API and frontend development server
"""
import os
import sys
import subprocess
import time
import signal
from pathlib import Path
def check_dependencies():
"""Check if required dependencies are installed"""
print("π Checking dependencies...")
# Check Python dependencies
try:
import fastapi
import uvicorn
print("β
Python backend dependencies found")
except ImportError as e:
print(f"β Missing Python dependency: {e}")
print("π‘ Install with: pip install -r requirements_api.txt")
return False
# Check Node.js and npm
try:
result = subprocess.run(['node', '--version'], capture_output=True, text=True)
if result.returncode == 0:
print(f"β
Node.js {result.stdout.strip()} found")
else:
print("β Node.js not found")
return False
except FileNotFoundError:
print("β Node.js not found")
print("π‘ Install Node.js from: https://nodejs.org/")
return False
# Check if frontend dependencies are installed
frontend_path = Path(__file__).parent / "frontend"
node_modules = frontend_path / "node_modules"
if not node_modules.exists():
print("π¦ Installing frontend dependencies...")
try:
subprocess.run(['npm', 'install'], cwd=frontend_path, check=True)
print("β
Frontend dependencies installed")
except subprocess.CalledProcessError:
print("β Failed to install frontend dependencies")
return False
else:
print("β
Frontend dependencies found")
return True
def start_backend():
"""Start the backend API server"""
print("π Starting backend API server...")
backend_script = Path(__file__).parent / "backend_simple.py"
# Start the backend process
backend_process = subprocess.Popen([
sys.executable, str(backend_script)
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# Wait a moment for the server to start
time.sleep(3)
# Check if the process is still running
if backend_process.poll() is None:
print("β
Backend API server started on http://localhost:8000")
return backend_process
else:
stdout, stderr = backend_process.communicate()
print(f"β Backend failed to start:")
print(f"STDOUT: {stdout}")
print(f"STDERR: {stderr}")
return None
def start_frontend():
"""Start the frontend development server"""
print("π¨ Starting frontend development server...")
frontend_path = Path(__file__).parent / "frontend"
# Start the frontend process
frontend_process = subprocess.Popen([
'npm', 'run', 'dev'
], cwd=frontend_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# Wait a moment for the server to start
time.sleep(5)
# Check if the process is still running
if frontend_process.poll() is None:
print("β
Frontend development server started on http://localhost:3000")
return frontend_process
else:
stdout, stderr = frontend_process.communicate()
print(f"β Frontend failed to start:")
print(f"STDOUT: {stdout}")
print(f"STDERR: {stderr}")
return None
def main():
"""Main startup function"""
print("𧬠EvolDSL Professional Frontend Startup")
print("=" * 50)
# Check dependencies
if not check_dependencies():
print("\nβ Dependency check failed. Please resolve the issues above.")
sys.exit(1)
print("\nπ§ Starting services...")
# Start backend
backend_process = start_backend()
if not backend_process:
print("β Failed to start backend. Exiting.")
sys.exit(1)
# Start frontend
frontend_process = start_frontend()
if not frontend_process:
print("β Failed to start frontend. Stopping backend and exiting.")
backend_process.terminate()
sys.exit(1)
print("\nπ EvolDSL is ready!")
print("=" * 50)
print("π Frontend: http://localhost:3000")
print("π Backend API: http://localhost:8000")
print("π API Docs: http://localhost:8000/docs")
print("=" * 50)
print("π‘ Tips:")
print(" β’ Enter your GPT-4o API key in the control panel")
print(" β’ Configure MCTS and Evolution parameters")
print(" β’ Click 'Start Evolution' to begin")
print(" β’ Watch the real-time visualization!")
print("=" * 50)
print("π Press Ctrl+C to stop both servers")
def signal_handler(sig, frame):
print("\n\nπ Shutting down EvolDSL...")
backend_process.terminate()
frontend_process.terminate()
# Wait for processes to terminate
backend_process.wait()
frontend_process.wait()
print("β
All services stopped. Goodbye!")
sys.exit(0)
# Handle Ctrl+C gracefully
signal.signal(signal.SIGINT, signal_handler)
try:
# Keep the script running and monitor processes
while True:
time.sleep(1)
# Check if processes are still running
if backend_process.poll() is not None:
print("β Backend process died unexpectedly")
break
if frontend_process.poll() is not None:
print("β Frontend process died unexpectedly")
break
except KeyboardInterrupt:
pass # Handled by signal handler
finally:
# Cleanup
if backend_process and backend_process.poll() is None:
backend_process.terminate()
if frontend_process and frontend_process.poll() is None:
frontend_process.terminate()
if __name__ == "__main__":
main()