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
stop.py · 1.3 KB · 42 lines
1"""Stop DBBasic services"""
2
3import os
4import signal
5import typer
6from rich.console import Console
7import psutil
8
9from .config import SERVICES, get_pid, remove_pid
10
11console = Console()
12
13def stop(service: str = typer.Argument(None, help="Service to stop (omit for all)")):
14 """Stop DBBasic services"""
15
16 if service and service not in SERVICES:
17 console.print(f"[red]Unknown service: {service}[/red]")
18 console.print(f"Available: {', '.join(SERVICES.keys())}")
19 raise typer.Exit(1)
20
21 services_to_stop = [service] if service else list(SERVICES.keys())
22
23 for svc_name in services_to_stop:
24 svc = SERVICES[svc_name]
25 pid = get_pid(svc_name)
26
27 if pid and psutil.pid_exists(pid):
28 try:
29 os.kill(pid, signal.SIGTERM)
30 console.print(f"✅ Stopped {svc['name']}")
31 remove_pid(svc_name)
32 except ProcessLookupError:
33 console.print(f"[yellow]{svc['name']} not running[/yellow]")
34 remove_pid(svc_name)
35 except Exception as e:
36 console.print(f"[red]❌ Failed to stop {svc['name']}: {e}[/red]")
37 else:
38 console.print(f"[dim]{svc['name']} not running[/dim]")
39 remove_pid(svc_name)
40
41 if not service:
42 console.print("\n[bold]All services stopped[/bold]")