Background processes
- Never run a server in the foreground of a tool call. It runs until the
timeout kills it and the round is wasted. Background it and detach:
bash -lc "nohup bun run dev > /tmp/dev.log 2>&1 & echo started". - Logs go to a file, not the pipe. A backgrounded process writing to the
pipe keeps the call alive. Redirect to
/tmp/<name>.log, then read the log withtail -20 /tmp/<name>.login a later call. - Wait by polling the port, never by sleeping.
for i in $(seq 1 40); do curl -s localhost:3000 >/dev/null && echo UP && break; sleep 0.5; done - Verify it actually started. After the poll, check the log tail for the
startup line or errors:
tail -5 /tmp/dev.log. A backgrounded crash looks identical to success until you look. - Kill by pattern when done or when restarting.
pkill -f "bun run dev" || truebefore starting a second instance; two servers on one port is a classic wasted hour. - One-shot beats long-lived when possible. Prefer
bun run buildplus a static check over starting a dev server, andcargo testovercargo watch. Reach for a background server only when the task needs a live process.