askrobots / dbbasic-cli
Public
Make a complete, running app (a CRM, a shop, a blog) with one command, such as dbbasic crm.
config.py · 1.8 KB · 70 lines
| 1 | """ |
| 2 | Service configuration and registry |
| 3 | """ |
| 4 | |
| 5 | from pathlib import Path |
| 6 | from ..bootstrap import get_dbbasic_dir |
| 7 | |
| 8 | # Base directory for DBBasic (auto-installs if needed) |
| 9 | DBBASIC_DIR = get_dbbasic_dir() |
| 10 | |
| 11 | # Service registry |
| 12 | SERVICES = { |
| 13 | "crud": { |
| 14 | "name": "CRUD Engine", |
| 15 | "module": "dbbasic_crud_engine", |
| 16 | "port": 8005, |
| 17 | "url": "http://localhost:8005", |
| 18 | "description": "Data management interface" |
| 19 | }, |
| 20 | "monitor": { |
| 21 | "name": "Real-time Monitor", |
| 22 | "module": "realtime_monitor", |
| 23 | "port": 8004, |
| 24 | "url": "http://localhost:8004", |
| 25 | "description": "System dashboard" |
| 26 | }, |
| 27 | "ai": { |
| 28 | "name": "AI Service Builder", |
| 29 | "module": "dbbasic_ai_service_builder", |
| 30 | "port": 8003, |
| 31 | "url": "http://localhost:8003", |
| 32 | "description": "AI-powered service generator" |
| 33 | }, |
| 34 | "event": { |
| 35 | "name": "Event Store", |
| 36 | "module": "dbbasic_event_store", |
| 37 | "port": 8007, |
| 38 | "url": "http://localhost:8007", |
| 39 | "description": "Event sourcing system" |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | # PID file location |
| 44 | PID_DIR = Path.home() / ".dbbasic" / "pids" |
| 45 | PID_DIR.mkdir(parents=True, exist_ok=True) |
| 46 | |
| 47 | def get_pid_file(service_name): |
| 48 | """Get PID file path for a service""" |
| 49 | return PID_DIR / f"{service_name}.pid" |
| 50 | |
| 51 | def save_pid(service_name, pid): |
| 52 | """Save process PID""" |
| 53 | pid_file = get_pid_file(service_name) |
| 54 | pid_file.write_text(str(pid)) |
| 55 | |
| 56 | def get_pid(service_name): |
| 57 | """Get saved PID for service""" |
| 58 | pid_file = get_pid_file(service_name) |
| 59 | if pid_file.exists(): |
| 60 | try: |
| 61 | return int(pid_file.read_text().strip()) |
| 62 | except: |
| 63 | return None |
| 64 | return None |
| 65 | |
| 66 | def remove_pid(service_name): |
| 67 | """Remove PID file""" |
| 68 | pid_file = get_pid_file(service_name) |
| 69 | if pid_file.exists(): |
| 70 | pid_file.unlink() |