Mac 부팅과 함께 시작되는 장기 프로세스
웹 서버, DB, 메시지 브로커 — 부팅 시 시작 + 크래시 시 재시작 필요. macOS 는 launchd 가 관리. 위에 편의 front end 둘:
brew services— Homebrew 로 깐 도구용.launchctl— 임의 plist 의 raw command.
brew services
brew install postgresql@16
brew services start postgresql@16
brew services list
brew services stop postgresql@16
brew services restart postgresql@16
# 로그인 시 자동 시작 없이 실행
brew services run postgresql@16내부적으로 brew 가 LaunchAgent plist 를 ~/Library/LaunchAgents/ 에 작성 + load.
launchctl 직접
# 사용자에 load 된 거 보기
launchctl list | grep -v com.apple
# plist load
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/com.me.svc.plist
# unload
launchctl bootout gui/$UID/com.me.svc
# 깔끔 재시작
launchctl kickstart -k gui/$UID/com.me.svcLaunchAgent vs LaunchDaemon
- LaunchAgent — 로그인 시 사용자로 실행.
~/Library/LaunchAgents/또는/Library/LaunchAgents/. - LaunchDaemon — root 로 부팅 시 (사용자 로그인 전) 실행.
/Library/LaunchDaemons/.
Pippa 의 pippa serve 는 LaunchAgent 면 충분 — 사용자 로그인 후 너로 도라. root 필요 + 로그인 전 시작 아니면 LaunchDaemon 까진 안 가.
로그
plist 의 StandardOutPath / StandardErrorPath 가 launchd 의 출력 목적지. 없으면 출력 drop. 디버깅 시 항상 설정.