Make a complete, running app (a CRM, a shop, a blog) with one command, such as dbbasic crm.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-cli.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-cli.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-cli.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 Version 0.1.2: Working instant apps! a36b93a 1 year, 2 months ago History
logs.py · 2.1 KB · 58 lines
1"""View logs from DBBasic services"""
2
3import subprocess
4import typer
5from rich.console import Console
6import time
7from pathlib import Path
8
9from .config import SERVICES, DBBASIC_DIR, get_pid
10import psutil
11
12console = Console()
13
14def logs(
15 service: str = typer.Argument(None, help="Service to show logs for (omit for all)"),
16 follow: bool = typer.Option(False, "--follow", "-f", help="Follow log output"),
17 tail: int = typer.Option(50, "--tail", "-n", help="Number of lines to show")
18):
19 """View logs from DBBasic services"""
20
21 if service and service not in SERVICES:
22 console.print(f"[red]Unknown service: {service}[/red]")
23 console.print(f"Available: {', '.join(SERVICES.keys())}")
24 raise typer.Exit(1)
25
26 console.print(f"[bold]Showing logs{' (following)' if follow else ''}[/bold]\n")
27
28 # For now, inform user about log locations
29 # In production, we'd capture logs to files or use journald
30
31 if service:
32 svc = SERVICES[service]
33 pid = get_pid(service)
34 if pid and psutil.pid_exists(pid):
35 console.print(f"[green]✅ {svc['name']} is running (PID: {pid})[/green]")
36 console.print(f"Port: {svc['port']}")
37 console.print(f"URL: {svc['url']}")
38 else:
39 console.print(f"[yellow]⚠️ {svc['name']} is not running[/yellow]")
40 else:
41 # Show status of all services
42 for svc_name, svc in SERVICES.items():
43 pid = get_pid(svc_name)
44 if pid and psutil.pid_exists(pid):
45 console.print(f"[green]✅ {svc['name']}[/green] (PID: {pid}) on port {svc['port']}")
46 else:
47 console.print(f"[dim]❌ {svc['name']} not running[/dim]")
48
49 console.print("\n[dim]Note: In a future version, logs will be captured and displayed here.[/dim]")
50 console.print("[dim]For now, services output to their respective terminals.[/dim]")
51
52 if follow:
53 console.print("\n[yellow]Press Ctrl+C to stop following logs[/yellow]")
54 try:
55 while True:
56 time.sleep(1)
57 except KeyboardInterrupt:
58 console.print("\n[bold]Stopped following logs[/bold]")