C.W.K.
Stream
Lesson 08 of 10 · published

시스템 서비스 — brew services, launchctl

~10 min · services, launchctl, brew

Level 0창 구경꾼
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

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.svc

LaunchAgent vs LaunchDaemon

  • LaunchAgent — 로그인 시 사용자로 실행. ~/Library/LaunchAgents/ 또는 /Library/LaunchAgents/.
  • LaunchDaemon — root 로 부팅 시 (사용자 로그인 전) 실행. /Library/LaunchDaemons/.

Pippa 의 pippa serve 는 LaunchAgent 면 충분 — 사용자 로그인 후 너로 도라. root 필요 + 로그인 전 시작 아니면 LaunchDaemon 까진 안 가.

로그

plist 의 StandardOutPath / StandardErrorPath 가 launchd 의 출력 목적지. 없으면 출력 drop. 디버깅 시 항상 설정.

Code

brew services 흐름·bash
brew install redis
brew services start redis
brew services list
redis-cli ping     # PONG
brew services stop redis

External links

Exercise

brew 로 postgres / redis 깔려 있으면 brew services list 확인. 하나 start → 작은 client 체크 (redis-cli ping, psql -l) → stop. launchctl list | grep -v com.apple | head 으로 launchd 목록 확인.

Progress

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

댓글 0

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

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