점프투플라스크 4-10 질문드립니다.

[파일 구성도]
home/owl/server/projects/myproject 폴더에 config, owl폴더가 있음
home/owl/server/projects/myproject/owl 폴더에 static, templates, views 폴더가 위치하고 있음.
home/owl/server/venvs/owl/ 폴더에 bin, include, lib, lib64 등 폴더 저장되고있음

[파일명:/etc/nginx/sites-available/myproject의 내용]
server {
listen 80;
server_name 59.22.XXX.XXX;
location = /favicon.ico { access_log off; log_not_found off; }
location /static {
alias /home/owl/server/projects/myproject/nis/static;
}
location / {
include proxy_params;
proxy_pass http://unix:/tmp/myproject.sock;
}
}

[파일명: /etc/systemd/system/myproject.service의 내용]
[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=owl
Group=owl
WorkingDirectory=/home/owl/server/projects/myproject
EnvironmentFile=/home/owl/server/venvs/myproject.env
ExecStart=/home/owl/server/venvs/owl/bin/gunicorn \
--workers 2 \
--bind unix:/tmp/myproject.sock \
"owl:create_app()"

[Install]
WantedBy=multi-user.target

[systemctl status myproject.service 실행시 나오는 에러코드]
myproject.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/myproject.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2023-07-10 09:55:30 KST; 567ms ago
Process: 3721 ExecStart=/home/owl/server/venvs/owl/bin/gunicorn --workers 2 --bind unix:/tmp/myproject.sock owl:create_app() (code=exited, status=3)
Main PID: 3721 (code=exited, status=3)
CPU: 3.583s

7월 10 09:55:30 owl-server gunicorn[3723]: File "/usr/lib/python3.10/logging/config.py", line 572, in configure
7월 10 09:55:30 owl-server gunicorn[3723]: raise ValueError('Unable to configure handler '
7월 10 09:55:30 owl-server gunicorn[3723]: ValueError: Unable to configure handler 'file'
7월 10 09:55:30 owl-server gunicorn[3723]: [2023-07-10 09:55:30 +0900] [3723] [INFO] Worker exiting (pid: 3723)
7월 10 09:55:30 owl-server gunicorn[3721]: [2023-07-10 09:55:30 +0900] [3721] [WARNING] Worker with pid 3723 was terminated due to signal 15
7월 10 09:55:30 owl-server gunicorn[3721]: [2023-07-10 09:55:30 +0900] [3721] [INFO] Shutting down: Master
7월 10 09:55:30 owl-server gunicorn[3721]: [2023-07-10 09:55:30 +0900] [3721] [INFO] Reason: Worker failed to boot.
7월 10 09:55:30 owl-server systemd[1]: myproject.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
7월 10 09:55:30 owl-server systemd[1]: myproject.service: Failed with result 'exit-code'.
7월 10 09:55:30 owl-server systemd[1]: myproject.service: Consumed 3.583s CPU time.

[서버 구성]
시놀로지 VMM(가상머신) 우분투 서버 22.04 LTS (데스크탑 gui 설치해서 사용중)
4코어, 4GB램 할당해서 사용중

[특이사항]

<systemctl stop myproject.service>
<systemctl stop nginx>

두개 실행후
가상환경에서

<flask run --host=192.168.0.XX(공유기 내부ip)> 

실행시 잘 작동함

<systemctl start nginx>

실행후 nginx -t 실행시
nginx: configuration file /etc/nginx/nginx.conf test is successful 메시지 나옴

<gunicorn --bind 0:5000 "owl:create_app()">

실행시 사이트 접속이 가능함(192.168.0.XX ip로만 접속가능)

<gunicorn --bind unix:/tmp/myproject.sock "owl:create_app()">

위의 코드 실행시와 같은 문구로 서버가 정상작동 하는것 처럼 보임.

  1. myproject.service파일이 실행이 안되는게 제일 큰것 같습니다.
  2. 공유기 내부 ip를 입력하면 실행이 되는데 외부 ip(59.22.XXX.XXX)를 입력했을때 외부ip가 작동하지 않습니다.

등의 2가지 문제가 현재 있는데요, 고견을 여쭙고자 글을 작성합니다. 감사합니다.

OWL 343

M 2023년 7월 10일 10:25 오전

오류는 ValueError: Unable to configure handler 'file' 이 부분에서 발생한것 같습니다. 로깅 설정한 파일에 경로나 기타 오류가 발생할 만한 것이 있는지 확인해 보세요. 그리고 외부 아이피의 경우에는 IP를 0.0.0.0로 실행하시고 공유기 방화벽 포트등도 확인해 보세요. - 박응용님, 2023년 7월 10일 10:38 오전 추천 , 대댓글
목록으로