summaryrefslogtreecommitdiffstats
path: root/cmd/ship/status.go
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-01-24 09:48:34 -0800
committerbndw <ben@bdw.to>2026-01-24 09:48:34 -0800
commit5861e465a2ccf31d87ea25ac145770786f9cc96e (patch)
tree4ac6b57a06b46d8492717b235909f9e0db0b4f22 /cmd/ship/status.go
parentef37850c7090493cf2b26d2e565511fe23cc9bfc (diff)
Rename project from deploy to ship
- Rename module to github.com/bdw/ship - Rename cmd/deploy to cmd/ship - Update all import paths - Update config path from ~/.config/deploy to ~/.config/ship - Update VPS env path from /etc/deploy to /etc/ship - Update README, Makefile, and docs
Diffstat (limited to 'cmd/ship/status.go')
-rw-r--r--cmd/ship/status.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/cmd/ship/status.go b/cmd/ship/status.go
new file mode 100644
index 0000000..03c548b
--- /dev/null
+++ b/cmd/ship/status.go
@@ -0,0 +1,60 @@
1package main
2
3import (
4 "fmt"
5
6 "github.com/bdw/ship/internal/ssh"
7 "github.com/bdw/ship/internal/state"
8 "github.com/spf13/cobra"
9)
10
11var statusCmd = &cobra.Command{
12 Use: "status <app>",
13 Short: "Check status of a deployment",
14 Args: cobra.ExactArgs(1),
15 RunE: runStatus,
16}
17
18func runStatus(cmd *cobra.Command, args []string) error {
19 name := args[0]
20
21 st, err := state.Load()
22 if err != nil {
23 return fmt.Errorf("error loading state: %w", err)
24 }
25
26 host := hostFlag
27 if host == "" {
28 host = st.GetDefaultHost()
29 }
30
31 if host == "" {
32 return fmt.Errorf("--host is required")
33 }
34
35 app, err := st.GetApp(host, name)
36 if err != nil {
37 return err
38 }
39
40 if app.Type != "app" {
41 return fmt.Errorf("status is only available for apps, not static sites")
42 }
43
44 client, err := ssh.Connect(host)
45 if err != nil {
46 return fmt.Errorf("error connecting to VPS: %w", err)
47 }
48 defer client.Close()
49
50 output, err := client.RunSudo(fmt.Sprintf("systemctl status %s", name))
51 if err != nil {
52 // systemctl status returns non-zero for non-active services
53 // but we still want to show the output
54 fmt.Print(output)
55 return nil
56 }
57
58 fmt.Print(output)
59 return nil
60}