askrobots / dbbasic Public

Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.

0 downloads

dbbasic/launch_dbbasic.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add DBBasic crate engine logo and update README 0d628db 1 year, 2 months ago History
launch_dbbasic.py · 3.9 KB · 129 lines
1#!/usr/bin/env python3
2"""
3DBBasic Unified Service Launcher
4Start all DBBasic services with presentation layer
5"""
6
7import subprocess
8import time
9import signal
10import sys
11from pathlib import Path
12
13class DBBasicLauncher:
14 def __init__(self):
15 self.processes = []
16
17 # Service configurations
18 self.services = [
19 {
20 'name': 'Real-time Monitor',
21 'file': 'realtime_monitor.py',
22 'port': 8004,
23 'color': '\033[92m' # Green
24 },
25 {
26 'name': 'Data Service',
27 'file': 'dbbasic_crud_engine.py',
28 'port': 8005,
29 'color': '\033[94m' # Blue
30 },
31 {
32 'name': 'AI Service Builder',
33 'file': 'dbbasic_ai_service_builder.py',
34 'port': 8003,
35 'color': '\033[95m' # Purple
36 },
37 {
38 'name': 'Event Store',
39 'file': 'dbbasic_event_store.py',
40 'port': 8006,
41 'color': '\033[93m' # Yellow
42 }
43 ]
44
45 def start_service(self, service):
46 """Start a single service"""
47 if not Path(service['file']).exists():
48 print(f"❌ {service['name']}: File not found - {service['file']}")
49 return None
50
51 try:
52 process = subprocess.Popen(
53 ['python', service['file']],
54 stdout=subprocess.PIPE,
55 stderr=subprocess.STDOUT,
56 universal_newlines=True,
57 bufsize=1
58 )
59
60 print(f"{service['color']}✅ {service['name']} started on port {service['port']}\033[0m")
61 return process
62 except Exception as e:
63 print(f"❌ Failed to start {service['name']}: {e}")
64 return None
65
66 def start_all(self):
67 """Start all services"""
68 print("=" * 60)
69 print("🚀 DBBasic Platform Launcher")
70 print("=" * 60)
71 print("\nStarting all services...\n")
72
73 for service in self.services:
74 process = self.start_service(service)
75 if process:
76 self.processes.append(process)
77 time.sleep(2) # Give each service time to start
78
79 print("\n" + "=" * 60)
80 print("✅ All services started!")
81 print("=" * 60)
82 print("\n📌 Service URLs:")
83 print(" • Dashboard: http://localhost:8004")
84 print(" • Data Service: http://localhost:8005")
85 print(" • AI Services: http://localhost:8003")
86 print(" • Event Store: http://localhost:8006")
87 print(" • API Docs: http://localhost:8005/docs")
88 print("\nPress Ctrl+C to stop all services\n")
89
90 # Monitor processes
91 try:
92 while True:
93 for i, process in enumerate(self.processes):
94 if process.poll() is not None:
95 print(f"⚠️ Service {self.services[i]['name']} stopped")
96 # Restart the service
97 self.processes[i] = self.start_service(self.services[i])
98 time.sleep(5)
99 except KeyboardInterrupt:
100 self.stop_all()
101
102 def stop_all(self):
103 """Stop all services"""
104 print("\n\nStopping all services...")
105
106 for process in self.processes:
107 if process:
108 process.terminate()
109
110 # Wait for processes to terminate
111 for process in self.processes:
112 if process:
113 process.wait()
114
115 print("✅ All services stopped")
116 sys.exit(0)
117
118 def signal_handler(self, sig, frame):
119 """Handle Ctrl+C"""
120 self.stop_all()
121
122if __name__ == "__main__":
123 launcher = DBBasicLauncher()
124
125 # Register signal handler
126 signal.signal(signal.SIGINT, launcher.signal_handler)
127
128 # Start all services
129 launcher.start_all()