Gunicorn被困在docker运行命令与Flask应用程序
我有我的容器app_container
内置,根据我的应用程序代码公开端口8000。 容器的入口点是ENTRYPOINT ["/usr/local/bin/gunicorn", "web_interface:app", "-w 4", "-t 90", "--log-level=info", "-b 127.0.0.1:8000", "--reload"]
。
当我用docker run --link postgres_db_container --name foo app_container
构build和运行容器时,它运行gunicorn命令到应用程序。 不像当我在本地运行应用程序,它停在
[2017-06-19 16:01:16 +0000] [1] [INFO] Starting gunicorn 19.7.1 [2017-06-19 16:01:16 +0000] [1] [INFO] Listening at: http://127.0.0.1:8000 [2017-06-19 16:01:16 +0000] [1] [INFO] Using worker: sync [2017-06-19 16:01:16 +0000] [8] [INFO] Booting worker with pid: 8 [2017-06-19 16:01:16 +0000] [10] [INFO] Booting worker with pid: 10 [2017-06-19 16:01:16 +0000] [11] [INFO] Booting worker with pid: 11 [2017-06-19 16:01:16 +0000] [13] [INFO] Booting worker with pid: 13
任何人都知道为什么gunicorn进程在这里停滞不前,并不会继续?
没有错误要继续。 所以,如果你有任何想法如何获得更多的信息,我所有的耳朵…
编辑:
当用control+c
取消进程时,我看到一个testing打印消息:
^C[2017-06-19 16:09:27 +0000] [1] [INFO] Handling signal: int [2017-06-19 16:09:27 +0000] [10] [INFO] Worker exiting (pid: 10) [2017-06-19 16:09:27 +0000] [11] [INFO] Worker exiting (pid: 11) [2017-06-19 16:09:27 +0000] [8] [INFO] Worker exiting (pid: 8) ---- Generate Mapping ---- ---- Preparing Databases ----
所以看起来gunicorn在某个过程中被挂起了,但是我不知道如何找出它是什么。
让我们给一些组合的build议:
-
检查您是否将端口映射到本地主机以访问容器应用程序:
docker run -p 8000:8000 (rest of the command)
-
听取
"-b 0.0.0.0:8000"
而不是"-b 127.0.0.1:8000"
,这是docker映射端口的要求。 所以看docker ps
,search符号->
在PORTS列(你应该看到0.0.0.0:8000->8000
->
0.0.0.0:8000->8000
。
然后,在浏览器中导航到localhost:8000
,检查您的应用程序是否正确呈现。