Resolved
Written on
·
531
1
14:30초 과정까지 따라가서
IP/board/list로 접속해봤지만 접속이 안됩니다...
뭐가 문제일까요...로그 기록 남겨드립니다..
강의하고 한가지 다른점은..저는 강의 내내 파이썬 3.8을 썼는데 도커 이미지가 3.8이 지원이 안되는거 같아서 3.7로 바꿔서 했습니다...그게 원인인건지...
/usr/lib/python2.7/dist-packages/supervisor/options.py:298: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
2020-03-09 12:59:12,918 CRIT Supervisor running as root (no user in config file)
2020-03-09 12:59:12,918 INFO Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2020-03-09 12:59:12,935 INFO RPC interface 'supervisor' initialized
2020-03-09 12:59:12,936 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-03-09 12:59:12,936 INFO supervisord started with pid 1
2020-03-09 12:59:13,939 INFO spawned: 'nginx' with pid 9
2020-03-09 12:59:13,941 INFO spawned: 'uwsgi' with pid 10
[uWSGI] getting INI configuration from /app/uwsgi.ini
[uWSGI] getting INI configuration from /etc/uwsgi/uwsgi.ini
;uWSGI instance configuration
[uwsgi]
cheaper = 2
processes = 16
ini = /app/uwsgi.ini
module = main
callable = app
i = /etc/uwsgi/uwsgi.ini
socket = /tmp/uwsgi.sock
own-socket = nginx:nginx
chmod-socket = 664
hook-master-start = unix_signal:15 gracefully_kill_them_all
need-app = true
die-on-term = true
show-config = true
;end of configuration
*** Starting uWSGI 2.0.18 (64bit) on [Mon Mar 9 12:59:14 2020] ***
compiled with version: 6.3.0 20170516 on 14 October 2019 23:20:32
os: Linux-5.0.0-1031-gcp #32-Ubuntu SMP Tue Feb 11 03:55:48 UTC 2020
nodename: 6abf79646e76
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /app
detected binary path: /usr/local/bin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.4 (default, Sep 12 2019, 16:02:06) [GCC 6.3.0 20170516]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55e9b9a27f50
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1239640 bytes (1210 KB) for 16 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x55e9b9a27f50 pid: 10 (default app)
2020-03-09 12:59:15,182 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-09 12:59:15,182 INFO success: uwsgi entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 10)
spawned uWSGI worker 1 (pid: 15, cores: 1)
spawned uWSGI worker 2 (pid: 16, cores: 1)
running "unix_signal:15 gracefully_kill_them_all" (master-start)...
{}
[2020-03-09 12:59:50,638] ERROR in app: Exception on /board/list [GET]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "./main/board.py", line 45, in lists
tot_count = board.find(query).count()
File "/usr/local/lib/python3.7/site-packages/pymongo/cursor.py", line 787, in count
cmd, self.__collation, session=self.__session)
File "/usr/local/lib/python3.7/site-packages/pymongo/collection.py", line 1600, in _count
_cmd, self._read_preference_for(session), session)
File "/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1454, in _retryable_read
read_pref, session, address=address)
File "/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1253, in _select_server
server = topology.select_server(server_selector)
File "/usr/local/lib/python3.7/site-packages/pymongo/topology.py", line 235, in select_server
address))
File "/usr/local/lib/python3.7/site-packages/pymongo/topology.py", line 193, in select_servers
selector, server_timeout, address)
File "/usr/local/lib/python3.7/site-packages/pymongo/topology.py", line 209, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
175.211.252.65 - - [09/Mar/2020:12:59:50 +0000] "GET /board/list HTTP/1.1" 500 290 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
[pid: 15|app: 0|req: 1/1] 175.211.252.65 () {44 vars in 1942 bytes} [Mon Mar 9 12:59:20 2020] GET /board/list => generated 290 bytes in 30083 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)
Answer 1
1
도커 셋팅을 할때 오류가 발생하면 정확이 어디서 오류가 나는지를 찾는게 우선입니다.
test.py 파일을 새로 만들어서 /test 라는 주소를 만들고 화면에 return "OK" 를 출력하는 샘플 코드를 작성한 후 해당 주소로 접속이 되는지 부터 확인해보셔야 할듯 합니다. 그렇게 OK 가 화면에 정상적으로 출력되면 uwsgi 에는 문제가 없고 파이썬 코드에서 문제가 생긴걸로 볼 수 있고 만약 /test 주소에도 접속이 안되면 uwsgi 쪽 설정 혹은 서버 설정에서 문제가 되는걸로 볼 수 있습니다.
파이썬은 따로 설치하지 말고 강좌에 나온 내용처럼 해당 버전이 있는 도커 이미지를 사용해서 설정하시는걸 추천합니다. 그리고 도커 적용시 하나하나 코드 테스트부터 해보셔서 코드에 문제가 100% 없다고 판단되었을때 그때 도커 작업을 하시는게 좋습니다. 나중에 문제가 생기면 어디서 문제가 생겼는지 찾기가 힘들어질 수 있습니다.