polats Claude Opus 5 (1M context) commited on
Commit
caf011b
·
1 Parent(s): edf5b8c

Instrument the start hook to find where the server is lost

Browse files

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. .devcontainer/devcontainer.json +4 -4
.devcontainer/devcontainer.json CHANGED
@@ -55,10 +55,10 @@
55
  // Runs on create *and* on every resume from an idle stop, which is what makes the codespace
56
  // behave like a server rather than a dev box you have to restart by hand.
57
  //
58
- // It goes through start-opencode.sh rather than straight to the entrypoint because
59
- // Codespaces secrets are not in this hook's environment — see that script. setsid detaches
60
- // the server from the shell, which exits as soon as the hook returns.
61
- "postStartCommand": "setsid nohup ${containerWorkspaceFolder}/.devcontainer/start-opencode.sh > /tmp/opencode.log 2>&1 < /dev/null & echo started",
62
 
63
  "customizations": {
64
  "vscode": {
 
55
  // Runs on create *and* on every resume from an idle stop, which is what makes the codespace
56
  // behave like a server rather than a dev box you have to restart by hand.
57
  //
58
+ // Diagnostic build: records whether the detached server is still alive after the hook
59
+ // returns, because a hook that launches a process and then loses it looks identical to one
60
+ // that never ran.
61
+ "postStartCommand": "bash -c 'D=/tmp/hook.log; { echo \"--- hook $(date -Is)\"; command -v setsid || echo \"no setsid\"; } >> $D 2>&1; setsid nohup ${containerWorkspaceFolder}/.devcontainer/start-opencode.sh >> /tmp/opencode.log 2>&1 < /dev/null & P=$!; echo \"launched pid=$P\" >> $D; sleep 5; if kill -0 $P 2>/dev/null; then echo \"alive after 5s\" >> $D; else echo \"DEAD after 5s\" >> $D; fi; pgrep -f opencode >> $D 2>&1 || echo \"no opencode process\" >> $D'",
62
 
63
  "customizations": {
64
  "vscode": {