[TALKITBANK] systemd를 활용한 웹 서비스용 시작/종료 스크립트 작성
안녕하세요 @talkit.bank 입니다.
서비스 주소
본문
요즘 talkit.bank에 계속 프로그램을 작성해보고 있습니다.
그런데 SSL로 전환하면서 표준 포트를 사용했습니다.
그래서 서버를 작동 시키려면 힘들게 해야 합니다. ^^
기존 방법
파이썬하고 친해지는 중이라서 좀 더 다른 방법이 있겠지만, ^^
시작
sudo -i
source /home/ubuntu/.bashrc
conda activate steemit
nohup gunicorn -w 4 -b 0.0.0.0:443 app:app --certfile=/etc/letsencrypt/live/talkitbank.whd.kr/fullchain.pem --keyfile=/etc/letsencrypt/live/talkitbank.whd.kr/privkey.pem --access-logfile access.log --error-logfile error.log --log-level info &
시작은 위와 같이 하고,
일부러 저화면안 안끕니다. ^^
근데 가끔 끄면 귀찮아지죠 ^^
종료
sudo -i
source /home/ubuntu/.bashrc
conda activate steemit
ps -ef | grep corn
kill -9 corn의pid들을 나열
위와 같이 수행 했습니다.
변경된 방법
시작
sudo systemctl start steemit-web
종료
sudo systemctl stop steemit-web
재시작
sudo systemctl restart steemit-web
상태확인
sudo systemctl status steemit-web
(steemit) ubuntu@instance-20241026-2231:~/steemit/exercise_web$ sudo systemctl status steemit-web
● steemit-web.service - Steemit Web App with Gunicorn
Loaded: loaded (/etc/systemd/system/steemit-web.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2025-03-23 02:25:06 UTC; 1min 24s ago
Main PID: 392514 (gunicorn)
Tasks: 5 (limit: 1078)
Memory: 116.6M
CPU: 4.734s
CGroup: /system.slice/steemit-web.service
├─392514 /home/ubuntu/anaconda3/envs/steemit/bin/python /home/ubuntu/anaconda3/envs/steemit/bin/gunicorn -w 4 -b 0.0.0.0:443 app:app --certfile>
├─392520 /home/ubuntu/anaconda3/envs/steemit/bin/python /home/ubuntu/anaconda3/envs/steemit/bin/gunicorn -w 4 -b 0.0.0.0:443 app:app --certfile>
├─392521 /home/ubuntu/anaconda3/envs/steemit/bin/python /home/ubuntu/anaconda3/envs/steemit/bin/gunicorn -w 4 -b 0.0.0.0:443 app:app --certfile>
├─392522 /home/ubuntu/anaconda3/envs/steemit/bin/python /home/ubuntu/anaconda3/envs/steemit/bin/gunicorn -w 4 -b 0.0.0.0:443 app:app --certfile>
└─392523 /home/ubuntu/anaconda3/envs/steemit/bin/python /home/ubuntu/anaconda3/envs/steemit/bin/gunicorn -w 4 -b 0.0.0.0:443 app:app --certfile>
Mar 23 02:25:06 instance-20241026-2231 systemd[1]: Started Steemit Web App with Gunicorn.
현재 상태는 위와 같이 잘 접속 되어 있습니다.
어제 저거 오류잡는다고 고생을 좀 했는데 ^^
로그 확인
journalctl -u steemit-web -f
상세 로그 확인은 위 명령어로 확인 할 수 있습니다.
감사합니다.
Posted through the ECblog app (https://blog.etain.club)
Upvoted! Thank you for supporting witness @jswit.