점프 투 장고[gunicorn service] 관련 질문입니다

먼저, 점프 투 장고를 통해서 너무 감사하게도 잘 만들고 배우고 있습니다.

4-09에서 구니콘 실행 시

sudo systemctl start gunicorn.service

이후에 오류 발생 시
/var/log/syslog 파일에서 오류가 난 원인을 확인하고 수정해야 한다.

라고 나와있는데요.

현재,

sudo systemctl status gunicorn.service
했을 때

gunicorn.service: Failed to execute command: Permission denied
gunicorn.service: Failed at step EXEC spawning /home/ubuntu/venvs/mysite.env: Permission denied
gunicorn.service: Failed with result 'exit-code'

라는 에러 메시지가 발생합니다.

혹시, 관리자 권한 때문에 발생하는 것인가 싶어서 이름/권한과 관련한 수정 방법을 찾아보고 있는데
알고 계시다면 알려주시면 정말 감사하겠습니다!

sismis123 3290

M 2020년 9월 19일 2:56 오후

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

/var/log/syslog 의 내용을 보여주세요.
그리고 혹시 책과 다르게 설정한 환경이 있으면 알려주세요.
소켓파일의 위치도 /tmp/ 밑이 맞는지 알려주세요.

박응용

2020년 9월 19일 3:35 오후

밑에 답변에 남겼습니다! - sismis123님, 2020년 9월 19일 4:00 오후 추천 , 대댓글

환경은 모두 다 똑같이 설정했으나,
초기 settings.py 다운로드 받았을 때 하나만 다르긴 합니다.

현재 base.py 는 다음과 같이 구성되어 있습니다.

from pathlib import Path
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent

...

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    BASE_DIR / "static",
    '/var/www/static/',
]

소켓 파일 위치는 점프 투 장고와 동일하게 했습니다.

syslog는

Sep 19 06:11:12 ip-172-26-5-222 systemd[1]: Started gunicorn daemon.
Sep 19 06:11:12 ip-172-26-5-222 systemd[141336]: gunicorn.service: Failed to execute command: Permission denied
Sep 19 06:11:12 ip-172-26-5-222 systemd[141336]: gunicorn.service: Failed at step EXEC spawning /home/ubuntu/venvs/mysite.env: Permission denied
Sep 19 06:11:12 ip-172-26-5-222 systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Sep 19 06:11:12 ip-172-26-5-222 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Sep 19 06:17:01 ip-172-26-5-222 CRON[143429]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 06:25:01 ip-172-26-5-222 CRON[146296]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
Sep 19 06:27:24 ip-172-26-5-222 systemd[1]: session-62.scope: Succeeded.
Sep 19 06:27:24 ip-172-26-5-222 systemd[1]: session-63.scope: Succeeded.
Sep 19 06:27:26 ip-172-26-5-222 systemd[1]: Started Session 66 of user ubuntu.
Sep 19 06:27:26 ip-172-26-5-222 systemd[1]: Started Session 67 of user ubuntu.
Sep 19 06:32:41 ip-172-26-5-222 systemd-resolved[413]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Sep 19 06:32:44 ip-172-26-5-222 systemd[1]: Reloading.

인 것 같습니다.

감사합니다.

sismis123

2020년 9월 19일 3:59 오후

+1 aws lightsail 을 사용하신건가요? user/group 이 ubuntu/ubuntu 로 실행되게 되어 있는 설정입니다. - 박응용님, 2020년 9월 19일 4:26 오후 추천 , 대댓글
@박응용님 네 맞습니다. lightsail 이용하고 있고, 인스턴스 이름은 dowha이지만 사용자 이름은 ubuntu입니다. - sismis123님, 2020년 9월 19일 4:31 오후 추천 , 대댓글
@sismis123님 /etc/systemd/system/gunicorn.service 파일 내용도 좀 보여주세요.. - 박응용님, 2020년 9월 19일 4:36 오후 추천 , 대댓글
@sismis123님 그리고 /tmp/gunicorn.sock 파일이 만약 있으면 삭제하고 다시 실행해 보세요. - 박응용님, 2020년 9월 19일 4:40 오후 추천 , 대댓글
@박응용님 gunicorn.service 파일 추가하였습니다! - sismis123님, 2020년 9월 19일 5:19 오후 추천 , 대댓글

/tmp/gunicorn.sock 삭제하고 실행했는데 같은 오류가 나오네요

gunicon.service 파일은 다음과 같습니다.

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

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

sismis123

2020년 9월 19일 5:19 오후

+1 이 파일이 문제였네요.. 다음처럼 수정해 주세요. 책에 있는 내용으로 수정하시면 됩니다. [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 1 \ --bind unix:/tmp/gunicorn.sock \ config.wsgi:application [Install] WantedBy=multi-user.target - 박응용님, M 2020년 9월 19일 5:41 오후 추천 , 대댓글
@박응용님 와 감사합니다ㅠㅠㅠㅠ엄청 헤맸는데 정상 작동하네요. sudo chmod 775 - 한 후에 gunicon.service 파일 수정했더니 해결했습니다 감사합니다!! http://3.34.67.108/ 에 제 첫 페이지를 오픈했어요:) - sismis123님, M 2020년 9월 19일 7:52 오후 추천 , 대댓글
@sismis123님 축하드립니다. 사이트가 아주 이쁘네요. - 박응용님, 2020년 9월 19일 7:52 오후 추천 , 대댓글
@박응용님 바로 도메인도 연결했습니다. http://infobeauty.kr 모두 덕분입니다:) 좋은 주말 되세요!!! - sismis123님, M 2020년 9월 19일 10:00 오후 추천 , 대댓글

xodrmf

2022년 6월 11일 10:14 오전