C.W.K.
Stream
Lesson 06 of 07 · published

Deployment, Monitoring, and Restart Discipline

~14 min · deployment, monitoring, restart, launchd

Level 0Observer
0 XP0/64 lessons0/13 achievements
0/150 XP to next level150 XP to go0% complete

Process supervisors keep things alive

Pick a supervisor (launchd on macOS, systemd on Linux, supervisord, k8s) and let it own restart-on-crash. Your service should never be the thing that decides 'I should restart myself' — that is what supervisors are for. cwkPippa runs under launchd; launchctl kickstart -k is the operator's restart command.

Health endpoints that mean something

A liveness endpoint returns 200 if the process is up. A readiness endpoint returns 200 only if dependencies are healthy (Anthropic reachable, DB writable, MCP servers responsive). Use the right one for the right consumer — supervisors want liveness; load balancers want readiness.

Self-editing services need cold restart

cwkPippa runs Uvicorn without --reload because the agent edits its own backend code routinely. Auto-reload during a self-edit causes partial-file restarts and crashes. The pattern: edit, save, run a controlled launchctl kickstart -k — predictable, debuggable, and visible in the StatusBar.

Principle: Supervisors restart, services do not. Health endpoints distinguish liveness from readiness. Self-editing systems need cold restart, not auto-reload.

Code

Liveness vs readiness·python
from fastapi import FastAPI, Response
import httpx

app = FastAPI()

@app.get("/healthz")
async def liveness():
    # Process is up. That is all this means.
    return {"status": "alive"}

@app.get("/readyz")
async def readiness(response: Response):
    # Are we ready to serve traffic? Check real dependencies.
    checks = {}
    try:
        r = await httpx.AsyncClient(timeout=2).get("https://api.anthropic.com/v1/health")
        checks["anthropic"] = r.status_code == 200
    except Exception as e:
        checks["anthropic"] = False
    checks["db"] = await db_check()
    if not all(checks.values()):
        response.status_code = 503
    return {"checks": checks}
launchd plist (sketch) for an always-on service·yaml
# ~/Library/LaunchAgents/com.example.pippa.plist (XML in reality)
# Key fields:
ProgramArguments:
  - /usr/local/bin/uvicorn
  - backend.main:app
  - --host=0.0.0.0
  - --port=8000
KeepAlive:
  SuccessfulExit: false
RunAtLoad: true
StandardOutPath: /var/log/pippa.out.log
StandardErrorPath: /var/log/pippa.err.log
# Restart with: launchctl kickstart -k gui/$(id -u)/com.example.pippa

External links

Exercise

For one service you operate, audit: which supervisor, what is the restart command, what is the health endpoint surface (liveness + readiness), how does the operator know when to restart. Document the gaps.
Hint
If you do not have a readiness check beyond '200 if process up', you are conflating two questions. Add the dependency probes.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.