본문 바로가기
Infra2024년 6월 11일1분 읽기

Linux systemd 서비스 관리 완벽 가이드

YS
김영삼
조회 1202

서비스 파일 작성

[Unit]
Description=My App
After=network.target

[Service]
Type=simple
User=www
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/node server.js
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

서비스 관리 명령어

systemctl start myapp
systemctl enable myapp  # 부팅 시 자동 시작
systemctl status myapp
journalctl -u myapp -f  # 실시간 로그

댓글 0

아직 댓글이 없습니다.
Ctrl+Enter로 등록