-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_dashboard.py
More file actions
75 lines (59 loc) · 2.17 KB
/
run_dashboard.py
File metadata and controls
75 lines (59 loc) · 2.17 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
#!/usr/bin/env python3
"""
Task Management Dashboard Runner
Simple script to launch the task management dashboard
"""
import subprocess
import sys
import os
import webbrowser
import time
from urllib.request import urlopen
from urllib.error import URLError
def check_port(port):
"""Check if a port is available."""
try:
urlopen(f"http://localhost:{port}", timeout=2)
return True
except URLError:
return False
def main():
print("🚀 Launching OpenClaw Task Management Dashboard...")
# Check if the port is already in use
port = 5000
if check_port(port):
print(f"⚠️ Port {port} appears to be in use. Please close any existing dashboard instances.")
return
# Get the directory where this script is located
script_dir = os.path.dirname(os.path.abspath(__file__))
# Check if api.py exists in the current directory
api_file = os.path.join(script_dir, "api.py")
if not os.path.exists(api_file):
print(f"❌ API file not found at {api_file}")
return
print(f"📂 Using API file from current directory: {script_dir}")
# Start the Flask server in a subprocess
print("🔌 Starting API server...")
server_process = subprocess.Popen([sys.executable, "api.py"])
# Wait a moment for the server to start
time.sleep(3)
# Check if the server started successfully
if server_process.poll() is not None:
print("❌ Failed to start the API server")
return
print(f"🌐 Opening dashboard in your browser at http://localhost:{port}")
# Open the browser to the dashboard
webbrowser.open(f"http://localhost:{port}")
print("✅ Dashboard launched successfully!")
print(f"💡 Access the dashboard at: http://localhost:{port}")
print("💡 Press Ctrl+C to stop the server")
try:
# Keep the script running to keep the server alive
server_process.wait()
except KeyboardInterrupt:
print("\n🛑 Shutting down dashboard server...")
server_process.terminate()
server_process.wait()
print("👋 Dashboard server stopped.")
if __name__ == "__main__":
main()