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

배포 · 모니터링 · 재시작 규율

~14 min · deployment, monitoring, restart, launchd

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

프로세스 supervisor가 살려둠

Supervisor 픽(macOS의 launchd, Linux의 systemd, supervisord, k8s) 후 그게 restart-on-crash 소유하게. Service가 절대 'I should restart myself' 결정하는 거 X — supervisor가 그거 위해. cwkPippa가 launchd 아래 run; launchctl kickstart -k가 운영자 재시작 명령.

의미 있는 health 엔드포인트

Liveness 엔드포인트가 프로세스 up이면 200 반환. Readiness 엔드포인트가 의존성 healthy(Anthropic reachable, DB writable, MCP 서버 responsive)일 때만 200 반환. 옳은 consumer에 옳은 거 — supervisor엔 liveness; 로드 밸런서엔 readiness.

Self-editing service는 cold restart 필요

cwkPippa가 Uvicorn을 --reload 없이 run — 에이전트가 자기 백엔드 코드 routinely 편집. Self-edit 동안 auto-reload가 partial-file restart와 crash 야기. 패턴 — 편집, save, controlled launchctl kickstart -k run — predictable, debuggable, StatusBar에 visible.

원칙: Supervisor가 재시작, service X. Health 엔드포인트가 liveness와 readiness 구분. Self-editing 시스템엔 cold restart, auto-reload X.

Code

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

app = FastAPI()

@app.get("/healthz")
async def liveness():
    # 프로세스 up. 그게 의미 전부.
    return {"status": "alive"}

@app.get("/readyz")
async def readiness(response: Response):
    # 트래픽 service 준비? 진짜 의존성 체크.
    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}
Always-on service 위한 launchd plist (sketch)·yaml
# ~/Library/LaunchAgents/com.example.pippa.plist (실제는 XML)
# Key 필드:
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
# 재시작 명령: launchctl kickstart -k gui/$(id -u)/com.example.pippa

External links

Exercise

운영하는 service 하나에 대해 audit — 어느 supervisor, 재시작 명령 뭐, health 엔드포인트 표면(liveness + readiness) 뭐, 운영자가 언제 재시작할지 어떻게 알아. Gap 문서화.
Hint
'프로세스 up이면 200' 너머 readiness 체크 없으면 두 질문 conflate 중. 의존성 probe 추가.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.