setup.sh: actually start the services, and verify they are running

setup.sh installed pm2 but never ran anything with it, so a fresh install
finished with every dependency in place and nothing listening. That is not
cosmetic: /desktop returns 503 until officer-vnc is connected, and chat needs
officer-claude.

Adds a step that runs `pm2 startOrRestart ecosystem.config.cjs`, saves the
process list, and enables the boot unit when it is not already there. Using
startOrRestart rather than start means apps added to the ecosystem since the last
run get picked up — officer-music is in the ecosystem on this box but was never
running, for exactly that reason.

The verification block now reports which services are up, with the names read
from ecosystem.config.cjs so the list cannot drift as sidecars are added.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
brunorezio
2026-07-26 05:19:27 +01:00
co-authored by Claude Opus 5
parent 7556c9ed00
commit 02662fc780
+51
View File
@@ -903,6 +903,43 @@ else
fi fi
fi fi
# ─── 19. start the services ──────────────────────────────────────────────────
echo ""
echo "── Services (pm2) ──"
# Installing pm2 is not the same as running anything with it. Without this the setup finishes with
# every dependency in place and nothing actually listening — and the sidecars matter beyond the web
# app: /desktop returns 503 until officer-vnc is connected, and chat needs officer-claude.
if ! has pm2 || [ ! -f "$PROJECT_DIR/ecosystem.config.cjs" ]; then
warn "Skipping service start (pm2 or ecosystem.config.cjs missing)"
else
# startOrRestart also picks up apps added to the ecosystem since the last run. These are all
# fork-mode apps, so reload would buy nothing over restart.
echo " Starting Officer and its sidecars..."
if (cd "$PROJECT_DIR" && pm2 startOrRestart ecosystem.config.cjs); then
ok "services started"
else
fail "pm2 could not start the services — check 'pm2 logs'"
fi
# Persist the process list so the boot unit has something to resurrect.
pm2 save >/dev/null 2>&1 && ok "process list saved" || warn "pm2 save failed"
# Boot persistence. pm2 startup writes a systemd unit; it needs root, and re-running it when the
# unit already exists is harmless.
if systemctl list-unit-files 2>/dev/null | grep -q "^pm2-$(whoami)\.service"; then
skip "pm2 boot service (pm2-$(whoami).service)"
else
echo " Enabling start on boot..."
if sudo env PATH="$PATH" pm2 startup systemd -u "$(whoami)" --hp "$HOME" >/dev/null 2>&1; then
pm2 save >/dev/null 2>&1
ok "services will start on boot"
else
warn "Could not enable boot startup — run: pm2 startup (and follow its instructions)"
fi
fi
fi
# ─── verification ───────────────────────────────────────────────────────────── # ─── verification ─────────────────────────────────────────────────────────────
echo "" echo ""
echo "═══════════════════════════════════════════" echo "═══════════════════════════════════════════"
@@ -973,6 +1010,20 @@ echo ""
echo "═══════════════════════════════════════════" echo "═══════════════════════════════════════════"
echo " Setup complete!" echo " Setup complete!"
echo "═══════════════════════════════════════════" echo "═══════════════════════════════════════════"
# Services actually running is a better signal than the binaries being present. The list comes from
# ecosystem.config.cjs so it cannot drift as sidecars are added.
if has pm2 && [ -f "$PROJECT_DIR/ecosystem.config.cjs" ]; then
echo ""
echo "Services:"
for app in $(grep -oE "name: *'[^']+'" "$PROJECT_DIR/ecosystem.config.cjs" | sed "s/.*'\(.*\)'/\1/"); do
if pm2 pid "$app" >/dev/null 2>&1 && [ -n "$(pm2 pid "$app" 2>/dev/null | tr -d '[:space:]')" ]; then
ok "$app"
else
fail "$app — not running (pm2 logs $app)"
fi
done
fi
echo "" echo ""
echo "Notes:" echo "Notes:"
echo " • PulseAudio null sink starts automatically with the server" echo " • PulseAudio null sink starts automatically with the server"