简体   繁体   English

Gunicorn 被 Flask 应用程序困在 docker run 命令上

[英]Gunicorn is stuck on docker run command with a Flask Application

I have my container app_container built, exposing port 8000 as per my application code.我已经构建了我的容器app_container ,根据我的应用程序代码公开了端口 8000。 The entry point to the container is ENTRYPOINT ["/usr/local/bin/gunicorn", "web_interface:app", "-w 4", "-t 90", "--log-level=info", "-b 127.0.0.1:8000", "--reload"] .容器的入口点是ENTRYPOINT ["/usr/local/bin/gunicorn", "web_interface:app", "-w 4", "-t 90", "--log-level=info", "-b 127.0.0.1:8000", "--reload"]

When I build and run the container with docker run --link postgres_db_container --name foo app_container , it runs the gunicorn command to the app.当我使用docker run --link postgres_db_container --name foo app_container构建并运行容器时,它会向应用程序运行 gunicorn 命令。 Unlike when i run the app locally, it stops at与我在本地运行应用程序时不同,它停在

[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

Anybody have a clue as to why the gunicorn process just stalls here, and does not continue?任何人都知道为什么 gunicorn 过程只是停在这里,而不是继续?

No errors to go on either.也没有错误可以继续。 So if you have any idea how to get more info, Im all ears...因此,如果您对如何获取更多信息有任何想法,我会全力以赴...

Edit:编辑:

When cancel the process with control+c , I see a test print message :当使用control+c取消进程时,我看到一条测试打印消息:

^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 ----

So it seems gunicorn is hung up on some process, but I dont know how to find out what it is.所以看起来 gunicorn 挂在了某个进程上,但我不知道如何找出它是什么。

Let's give some combo suggestions:让我们给出一些组合建议:

  • Check that you are mapping a port to your localhost in order to access the container app:检查您是否将端口映射到本地主机以访问容器应用程序:

     docker run -p 8000:8000 (rest of the command)
  • Listen to "-b 0.0.0.0:8000" instead of "-b 127.0.0.1:8000" , that is a requirement for docker to map ports."-b 0.0.0.0:8000"而不是"-b 127.0.0.1:8000" ,这是 docker 映射端口的要求。 So see docker ps , search for the symbol -> in PORTS column (you should see 0.0.0.0:8000->8000 .因此,请参阅docker ps ,在 PORTS 列中搜索符号-> (您应该看到0.0.0.0:8000->8000

Then, navigate to localhost:8000 in your web browser to check that your app properly renders.然后,在您的 Web 浏览器中导航到localhost:8000以检查您的应用程序是否正确呈现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM