[Linux] systemd 설정하기 (uwsgi, celery, celery beat)
[systemd 명령어]
systemctl start service
서비스 시작
systemctl stop service
서비스 종료
systemctl restart service
서비스 재시작
systemctl status service
서비스 상태
systemctl enable service
서비스를 서버 기동 시 자동으로 시작되도록 설정
systemctl disable service
서비스를 서버 기동 시 자동으로 시작되지 않도록 설정
[uwsgi 서비스 등록하기]
$ cd /etc/systemd/system
$ sudo vi uwsgi.service
아래 내용 추가 (빨간색은 해당 프로젝트에 맞게 변경)
[Unit]
Description=uWSGI
After=syslog.target
[Service]
ExecStart=/home/ubuntu/.virtualenvs/lotto/bin/uwsgi --ini /home/ubuntu/lotto/lotto_uwsgi.ini
# Requires systemd version 211 or newer
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
$ ls -al uwsgi.service
권한점검
-rw-r--r-- 1 root root 335 Jan 31 15:04 uwsgi.service
[celery, celery beat]
celery와 celerybeat는 설치 시 disable되어져 있으므로 아래의 명령어로 enable한다.
sudo systemctl enable celery
sudo systemctl enable celery beat
실행 시 pid 관련 에러가 나면 아래 사항을 점검
/var/run/celery 디렉토가 있는지 확인
없으면 /var/run/celery 디렉토리 생성
sudo mkdir /var/run/celery
sudo chown ubuntu /var/run/celery
sudo chgrp ubuntu /var/run/celery
댓글
댓글 쓰기