Gunicorn은 MyProject.sock 파일을 생성하지 않습니다.

Gunicorn은 MyProject.sock 파일을 생성하지 않습니다.

저는 Unix 전문가가 아니며 Ubuntu Server(20.04.5 LTS)의 Azure에서 WebApp을 실행하는 데 문제가 있습니다. gunicorn.service는 MyProjet.sock 파일을 생성하지 않습니다. 특히 WebApp은 항상 작동합니다. 어느 날부터 다음 날까지 MyProject.sock 파일이 삭제되어 다시 만들 수 없습니다.

여기와 StackOverflow에서 찾은 몇 가지 솔루션, 더 정확하게는 이 명령 시퀀스를 따라해 보았습니다.

sudo systemctl stop nginx 
sudo systemctl stop gunicorn.service
sudo systemctl restart nginx
sudo systemctl daemon-reload
sudo systemctl restart gunicorn.service
sudo systemctl status gunicorn.service

내가 얻는 결과는 다음과 같습니다

● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2024-01-12 13:40:11 UTC; 1min 18s ago
    Process: 2305577 ExecStart=/home/admin/myproject/backend/venv/bin/gunicorn --workers 3 --timeout 1800 --bind unix:/home/admin/myproject/backend/myproject.sock project.wsgi:application (code=exited, status=3)
   Main PID: 2305577 (code=exited, status=3)

Jan 12 13:40:10 DeployUbuntu gunicorn[2305583]: Inner error: {
Jan 12 13:40:10 DeployUbuntu gunicorn[2305583]:     "code": "ForbiddenByFirewall"
Jan 12 13:40:10 DeployUbuntu gunicorn[2305583]: }
Jan 12 13:40:10 DeployUbuntu gunicorn[2305583]: [2024-01-12 13:40:10 +0000] [2305583] [INFO] Worker exiting (pid: 2305583)
Jan 12 13:40:11 DeployUbuntu gunicorn[2305577]: [2024-01-12 13:40:11 +0000] [2305577] [WARNING] Worker with pid 2305584 was terminated due to signal 15
Jan 12 13:40:11 DeployUbuntu gunicorn[2305577]: [2024-01-12 13:40:11 +0000] [2305577] [WARNING] Worker with pid 2305583 was terminated due to signal 15
Jan 12 13:40:11 DeployUbuntu gunicorn[2305577]: [2024-01-12 13:40:11 +0000] [2305577] [INFO] Shutting down: Master
Jan 12 13:40:11 DeployUbuntu gunicorn[2305577]: [2024-01-12 13:40:11 +0000] [2305577] [INFO] Reason: Worker failed to boot.
Jan 12 13:40:11 DeployUbuntu systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Jan 12 13:40:11 DeployUbuntu systemd[1]: gunicorn.service: Failed with result 'exit-code'.

명령어를 연결해서 한번에 모든 명령어를 실행하려고 하면 서비스가 잘 되는 것 같더라구요

sudo systemctl stop nginx && sudo systemctl stop gunicorn.service && sudo systemctl restart nginx && sudo systemctl daemon-reload && sudo systemctl restart gunicorn.service && sudo systemctl status gunicorn.service
● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2024-01-12 13:40:10 UTC; 22ms ago
   Main PID: 2305577 (gunicorn)
      Tasks: 1 (limit: 9530)
     Memory: 2.8M
     CGroup: /system.slice/gunicorn.service
             └─2305577 /home/admin/myproject/backend/venv/bin/python /home/admin/myproject/backend/venv/bin/gunicorn --workers 3 --timeout 1800 --bind unix:/home/admin/myproject/backend/myproject.sock project.wsgi>
Jan 12 13:40:10 DeployUbuntu systemd[1]: Started gunicorn daemon.

하지만 즉시 실행하면

sudo systemctl status gunicorn.service

위에서 언급한 오류 메시지가 표시되었습니다.

구르니콘 서비스

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=admin
Group=www-data
WorkingDirectory=/home/admin/myproject/backend
ExecStart=/home/admin/myproject/backend/venv/bin/gunicorn --workers 3 --timeout 1800 --bind unix:/home/admin/myproject/backend/myproject.sock project.wsgi:application

[Install]
WantedBy=multi-user.target

gunicorn과 프로젝트를 제거하고 다시 설치해 보았다는 점을 덧붙이고 싶습니다. 마지막으로, 사용된 gunicorn 버전이 20.1.0이라는 점을 덧붙이고 싶습니다. 이는 프로젝트 사양 때문입니다.

관련 정보