장고 4-09 Gunicorn 서비스 등록 관련

4-09를 진행하면서 status mysite로 확인했는데 active가 failed 상태였어요. 경로도 책과 비교하면서 확인해봤는데, 문제점을 알 수가 없어서 질문올립니다. /var/log/syslog 를 통해 확인한 오류는 이렇게 나오는데 왜 No such file or directory가 나오는 지 모르겠어요.
/etc/systemd/system/mysite.service

GNU nano 4.8                                           /etc/systemd/system/mysite.service
[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/projects/mysite
EnvironmentFile=/home/ubuntu/venvs/mysite.env
ExecStart=/home/ubuntu/venvs/mysite/bin/gunicorn \
        --workers 2 \
        --bind unix:/tmp/gunicorn.sock \
        config.wsgi:application

[Install]
WantedBy=multi-user.target

/var/log/syslog

 Sep  2 05:41:57 ip-172-26-6-207 systemd[1]: /etc/systemd/system/mysite.service:15: Unknown section 'install'. Ignoring.
2113 Sep  2 05:41:57 ip-172-26-6-207 systemd[1]: Started gunicorn daemon.
2114 Sep  2 05:41:57 ip-172-26-6-207 systemd[15134]: mysite.service: Failed to execute command: No such file or directory
2115 Sep  2 05:41:57 ip-172-26-6-207 systemd[15134]: mysite.service: Failed at step EXEC spawning /home/ubuntu/venvs/mysite/bin/Gunicorn: No such      file or directory
2116 Sep  2 05:41:57 ip-172-26-6-207 systemd[1]: mysite.service: Main process exited, code=exited, status=203/EXEC
2117 Sep  2 05:41:57 ip-172-26-6-207 systemd[1]: mysite.service: Failed with result 'exit-code'.
2118 Sep  2 05:42:28 ip-172-26-6-207 systemd-networkd[424]: eth0: DHCPv6 address 2406:da12:d8d:8800:1ff5:6dc6:f0be:e41f/128 timeout preferred 150      valid 450
2119 Sep  2 05:42:49 ip-172-26-6-207 systemd[1]: /etc/systemd/system/mysite.service:15: Unknown section 'install'. Ignoring.
2120 Sep  2 05:43:43 ip-172-26-6-207 systemd-networkd[424]: eth0: DHCPv6 address 2406:da12:d8d:8800:1ff5:6dc6:f0be:e41f/128 timeout preferred 150      valid 450
2121 Sep  2 05:44:53 ip-172-26-6-207 systemd-networkd[424]: eth0: DHCPv6 address 2406:da12:d8d:8800:1ff5:6dc6:f0be:e41f/128 timeout preferred 150      valid 450

wmc1205 1200

2021년 9월 2일 4:25 오후

목록으로
1개의 답변이 있습니다. 1 / 1 Page

다음 파일이 실제 존재하는지 확인해 보세요.

/home/ubuntu/venvs/mysite/bin/Gunicorn

없다면 mysite 가상환경에서 gunicorn을 다시 설치해 보세요.
가상환경이 아닌 일반환경에서 설치하신듯 합니다.

박응용

2021년 9월 2일 6:30 오후

선생님 말씀대로 가상환경에서 설치가 안되어 있어서 생긴 문제가 맞네요! 감사합니다. 그러나 다른 문제가 생겼습니다 . handler 404와 handler 500을 하나는 예제에 맞게, 하나는 다른 방법으로 만들어보았습니다. 근데 로컬 환경에서는 404 page not found가 잘 뜨는데 왜 서버 환경에서는 Internal Server Error가 발생하는지 잘 모르겠습니다. DEBUG를 True로 고치고 확인했을 때, 로컬환경과 같이 404 page not found 가 잘 뜹니다. 나머지는 코드를 모두 동일하게 했으며, common/views 파일만 수정했는데 한번 확인 부탁드립니다. **views.py** ``` def page_not_found(request, exception, template_name="templates/common/404.html"): """ 404 Page Not Found """ return render(request, template_name, {}) def server_error(request, *args, **argv): return render(request, 'templates/common/500.html', status=500) ``` - wmc1205님, 2021년 9월 4일 3:15 오후 추천 , 대댓글
@wmc1205님 common/urls.py 에도 handler404 = 'common.views.page_not_found' 와 같은 코드를 작성하셔야 합니다. - 박응용님, 2021년 9월 4일 4:33 오후 추천 , 대댓글
@박응용님 다른 파일들은 교제에 맞게 모두 작성했습니다. view 파일만 수정했습니다. - wmc1205님, 2021년 9월 4일 5:32 오후 추천 , 대댓글