History

feat: supervise custom box services

Ben Davis committed 3 months ago

Commit 407c6331 parent 4d1f99b17 files · +1008 −24Browse files

Showing the changes to internal (5 of 17 files). Show all

Unified · Split

5 files
  1. internal/assets/assets.go +1 −1
  2. internal/assets/assets_test.go +4 −1
  3. internal/cli/cmd_logs.go +2 −2
  4. internal/cli/dispatch.go +1 −1
  5. internal/cli/dispatch_test.go +8 −0
internal/assets/assets.go+1−1
@@ -102,7 +102,7 @@ func fileMode(p string) int64 { · 101 unmodified lines
102102 switch {
103103 case strings.HasSuffix(p, ".sh"):
104104 return 0o755
105− case p == "guest/hb" || strings.HasPrefix(p, "guest/hb-"):
105+ case p == "guest/hb" || strings.HasPrefix(p, "guest/hb-") || p == "guest/tx9-services":
106106 return 0o755
107107 case p == "guest/hermes-state":
108108 return 0o755
internal/assets/assets_test.go+4−1
@@ -6,6 +6,7 @@ import ( · 5 unmodified lines
66 "io/fs"
77 "os"
88 "path/filepath"
9+ "strings"
910 "testing"
1011 )
1112
@@ -51,9 +52,11 @@ func TestBuildContextTar(t *testing.T) { · 39 unmodified lines
5152 if mode != 0o755 {
5253 t.Errorf("guest/hb mode = %o, want 0755", mode)
5354 }
54− for _, want := range []string{"box.env", "provision/provision.sh", "docker/entrypoint.sh", "docker/executor-entrypoint.sh", "guest/hb-workload", "guest/hermes-state"} {
55+ for _, want := range []string{"box.env", "provision/provision.sh", "docker/entrypoint.sh", "docker/executor-entrypoint.sh", "guest/hb-workload", "guest/tx9-services", "guest/hermes-state"} {
5556 if _, ok := modes[want]; !ok {
5657 t.Errorf("%s missing from build context tar", want)
58+ } else if strings.HasPrefix(want, "guest/") && modes[want] != 0o755 {
59+ t.Errorf("%s mode = %o, want 0755", want, modes[want])
5760 }
5861 }
5962 for name := range modes {
internal/cli/cmd_logs.go+2−2
@@ -42,7 +42,7 @@ func cmdLogs(args []string) error { · 41 unmodified lines
4242
4343 fs := flag.NewFlagSet("logs", flag.ContinueOnError)
4444 opts := logsQueryOptions{}
45− fs.StringVar(&opts.Source, "source", "all", "comma-separated sources: agent,executor,hermes,codex,claude")
45+ fs.StringVar(&opts.Source, "source", "all", "comma-separated sources: agent,executor,hermes,codex,claude,service-<name>")
4646 fs.IntVar(&opts.Tail, "tail", 200, "show the newest N matching events")
4747 fs.StringVar(&opts.Since, "since", "", "only events after a duration or RFC3339 timestamp (for example 24h)")
4848 fs.StringVar(&opts.Contains, "grep", "", "only events containing text")
@@ -89,7 +89,7 @@ func cmdLogsExport(args []string) error { · 40 unmodified lines
8989 fs := flag.NewFlagSet("logs export", flag.ContinueOnError)
9090 opts := logsQueryOptions{}
9191 output := fs.String("output", "", "output .tar.gz path (default: <box>-logs-<timestamp>.tar.gz)")
92− fs.StringVar(&opts.Source, "source", "all", "comma-separated sources: agent,executor,hermes,codex,claude")
92+ fs.StringVar(&opts.Source, "source", "all", "comma-separated sources: agent,executor,hermes,codex,claude,service-<name>")
9393 fs.StringVar(&opts.Since, "since", "", "only events after a duration or RFC3339 timestamp (for example 24h)")
9494 fs.StringVar(&opts.Contains, "grep", "", "only events containing text")
9595 fs.StringVar(&opts.Level, "level", "", "only events at this level or above: debug|info|warn|error (unleveled events count as info)")
internal/cli/dispatch.go+1−1
@@ -41,7 +41,7 @@ var commandSpecs = []commandSpec{ · 40 unmodified lines
4141 {name: "enter", help: "exec into a box's agent container (--executor for the executor container)", aliases: []string{"ssh", "shell"}, run: cmdEnter},
4242 {name: "start", help: "start a stopped box", run: cmdStart},
4343 {name: "stop", help: "stop a running box", run: cmdStop},
44− {name: "logs", help: "query/export durable agent, Executor, Hermes, Codex, and Claude events", run: cmdLogs},
44+ {name: "logs", help: "query/export durable agent, Executor, Hermes, Codex, Claude, and custom-service events", run: cmdLogs},
4545 {name: "resources", help: "show/update container limits and volume budgets", run: cmdResources},
4646 {name: "backup", help: "archive a box to a .tx9 file", aliases: []string{"export", "save"}, run: cmdBackup},
4747 {name: "import", help: "restore a box from a .tx9 file", aliases: []string{"load", "restore"}, run: cmdImport},
internal/cli/dispatch_test.go+8−0
@@ -59,6 +59,14 @@ func TestUsageShowsAliasesFromCommandSpecs(t *testing.T) { · 58 unmodified lines
5959 }
6060 }
6161
62+func TestUsageMentionsCustomServiceLogs(t *testing.T) {
63+ var usage bytes.Buffer
64+ printUsage(&usage)
65+ if !strings.Contains(usage.String(), "custom-service events") {
66+ t.Fatalf("logs help does not mention custom services:\n%s", usage.String())
67+ }
68+}
69+
6270 func TestNoArgumentsShowsOverviewAndCommands(t *testing.T) {
6371 var stdout, stderr bytes.Buffer
6472 status := runWithOverview([]string{"tx9"}, nil, func(w io.Writer) error {