blob: f47e081c2cfb98b5ffa8b1a77032acc1f0fe56e2 (
plain)
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
76
77
78
79
80
81
82
83
84
85
|
---
name: ship-status
description: Show what's running on a ship VPS. Derives state from the server — no local state file. Use when you want to know what apps are deployed, what ports they use, and whether they're running.
argument-hint: "[host-nickname]"
---
# ship-status
Show the current state of all deployments on a ship VPS by reading directly from the server.
## Read Config
Load the host from `~/.config/ship/config.json`. Use the default host unless a nickname was specified:
```bash
python3 -c "
import json, os, sys
cfg = json.load(open(os.path.expanduser('~/.config/ship/config.json')))
nick = sys.argv[1] if len(sys.argv) > 1 else cfg['default']
h = cfg['hosts'][nick]
print(h['host'])
print(h['domain'])
" <nickname-or-blank>
```
## Gather Server State
Run all of these in a single SSH session to minimize round trips:
**Systemd services (binary/docker apps):**
```bash
ssh <host> "systemctl list-units --type=service --state=active --no-pager --no-legend | grep -v '@' | awk '{print \$1}' | xargs -I{} sh -c 'name=\$(echo {} | sed s/.service//); port=\$(cat /etc/ship/ports/\$name 2>/dev/null); env=\$(cat /etc/ship/env/\$name.env 2>/dev/null | grep SHIP_URL | cut -d= -f2); echo \"\$name|\$port|\$env\"' 2>/dev/null | grep '|'"
```
**Static sites:**
```bash
ssh <host> "ls /var/www/ 2>/dev/null"
```
**Caddy configs (domains):**
```bash
ssh <host> "ls /etc/caddy/sites-enabled/ 2>/dev/null | grep -v '^$'"
```
**Caddy status:**
```bash
ssh <host> "systemctl is-active caddy"
```
**Disk usage for app data dirs:**
```bash
ssh <host> "du -sh /var/lib/*/ 2>/dev/null"
```
## Present Results
Format as a clean summary, for example:
```
HOST: prod (ubuntu@1.2.3.4)
SERVICES
foodtracker running :9013 https://foodtracker.example.com
myapi running :9014 https://api.example.com
STATIC SITES
mysite https://mysite.example.com
CADDY: running
DATA
/var/lib/foodtracker/ 48M
/var/lib/myapi/ 2M
```
If a service appears in `/etc/ship/ports/` but is not active in systemd, flag it as **stopped**.
If a Caddy config exists for a name but no service or static site matches, flag it as **orphaned config**.
## Notes
- No local state file is consulted — everything comes from the server
- If `~/.config/ship/config.json` doesn't exist, tell the user to run `/ship-setup` first
- If a nickname is given that doesn't exist in config, list available nicknames
- Use default host if no argument given
|