PEP-225: веб через свой сервер в launchd, переустановка агента веба при выкатке

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
peppa-bot 2026-11-20 21:04:14 +05:00
parent d3c29890f4
commit 0d86b801ee
2 changed files with 9 additions and 4 deletions

View File

@ -1,9 +1,10 @@
#!/usr/bin/env bash
# Installs Peppa's launchd agents (start at login, restart on crash):
# quest.telecom.peppa.watchdog — session watchdog under caffeinate -i (no idle sleep)
# quest.telecom.peppa.web — Next.js platform on :3100 (needs `pnpm --filter @peppa/web build`);
# PEPPA_WEB_MODE=dev runs `next dev` instead (HMR: edits in this
# checkout go live without build or release — the pre-launch setup)
# quest.telecom.peppa.web — Next.js platform on :3100 (needs `pnpm --filter @peppa/web build`)
# through its own server apps/web/server.ts (PEP-225: WebSocket
# /api/ws); a checkout without it (a rollback) — plain `next start`.
# PEPPA_WEB_MODE=dev runs it in dev mode (HMR)
# quest.telecom.peppa.bot — Telegram bot (TELEGRAM_BOT_TOKEN in .env)
# quest.telecom.peppa.observer — Observability monitors (PEP-202), own DB ~/.peppa/observe.db
# quest.telecom.peppa.release — Peppa's own prod releases (PEP-18): started by launchd while
@ -84,7 +85,7 @@ for s in "${SERVICES[@]}"; do
/usr/bin/caffeinate -i "$ROOT/packages/cli/bin/peppa" watchdog ;;
web)
install_agent quest.telecom.peppa.web web.log "$ROOT/apps/web" \
/bin/bash -c "set -a; . '$ROOT/.env'; set +a; exec '$ROOT/apps/web/node_modules/.bin/next' $WEB_MODE -p 3100" ;;
/bin/bash -c "set -a; . '$ROOT/.env'; set +a; if [ -f server.ts ]; then exec '$NODE_BIN' server.ts $([ "$WEB_MODE" = dev ] && echo --dev) -p 3100; else exec '$ROOT/apps/web/node_modules/.bin/next' $WEB_MODE -p 3100; fi" ;;
bot)
install_agent quest.telecom.peppa.bot bot.log "$ROOT" "$ROOT/apps/bot/bin/peppa-bot" ;;
observer)

View File

@ -128,6 +128,10 @@ say "built ${TARGET:0:8}"
# 7. Restart and health.
# PEP-202: the observer is restarted too once it is installed here.
restart() {
# PEP-225: the web agent of an older install starts `next start` directly — reinstall it once
# so it goes through apps/web/server.ts (the WebSocket channel); reinstalling restarts it.
local webplist="$HOME/Library/LaunchAgents/quest.telecom.peppa.web.plist"
if [ -f "$webplist" ] && ! grep -q 'server.ts' "$webplist"; then "$ROOT/scripts/install-launchd.sh" web >/dev/null; fi
for s in web watchdog bot; do launchctl kickstart -k "gui/$UIDN/quest.telecom.peppa.$s"; done
launchctl print "gui/$UIDN/quest.telecom.peppa.observer" >/dev/null 2>&1 && launchctl kickstart -k "gui/$UIDN/quest.telecom.peppa.observer" || true
}