【问题标题】:Handling ports in Azure using Flask Application使用 Flask 应用程序处理 Azure 中的端口
【发布时间】:2020-04-24 11:40:34
【问题描述】:

我对 Web 开发非常陌生,目前正在尝试在 Microsoft Azure 上部署 Flask 应用程序。部署成功,但是网站加载了很长时间然后崩溃... 我在应用程序日志中得到的错误如下:

2020-04-24 11:05:10.813 INFO  - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2020-04-24 11:05:14.160 INFO  - Initiating warmup request to container <container name> for site <appname>
2020-04-24 11:05:29.738 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 15.5776184 sec
2020-04-24 11:05:46.605 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 32.4451731 sec
2020-04-24 11:06:02.843 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 48.6833158 sec
2020-04-24 11:06:20.077 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 65.9168483 sec
2020-04-24 11:06:35.755 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 81.5946978 sec
2020-04-24 11:06:51.273 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 97.1126494 sec
2020-04-24 11:07:06.740 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 112.5797427 sec
2020-04-24 11:07:22.295 INFO  - Waiting for response to warmup request for container <container name>. Elapsed time = 128.1349342 sec
2020-04-24 11:09:28.785 ERROR - Container <container name> for site <appname> did not start within expected time limit. Elapsed time = 254.6249399 sec
2020-04-24 11:09:28.833 ERROR - Container <container name> didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2020-04-24 11:09:29.008 INFO  - Stoping site <appname> because it failed during startup.

我错过了什么?

在我的 main.py 文件中,我设置了 app.run(debug=True);所以没有指定端口和主机,可以吗? 在我设置的 Cloud Shell 中:

az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings WEBSITES_PORT=8000

有谁知道问题出在哪里?

一切顺利,
雪儿

【问题讨论】:

    标签: azure docker flask port web-deployment


    【解决方案1】:

    在 Azure App Service (Web App) 上托管您的 webapp,您只能使用端口 80 和 443。如果您需要自定义端口,则需要使用 Azure 虚拟机来托管您的应用程序

    【讨论】:

    • 那么我该如何指定它们呢?在 Flask main.py 文件中还是在 Azure Cloud Shell 中?
    • 我想你只需要将 WEBSITES_PORT=8000 切换到 WEBSITES_PORT=80
    • 它仍然在崩溃,但我刚刚在我的日志中发现了这个:2020-04-24T17:29:36.035250130Z 2020-04-24 17:29:36.035021: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory 2020-04-24T17:29:36.035859545Z 2020-04-24 17:29:36.035370: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303) 这也可能会导致问题......
    • 更新到我的最后一条评论:当我在本地运行应用程序时(一切正常),我得到了同样的错误。但是,它告诉我,当我不想使用 GPU(我不想)时,我可以忽略它。那么有没有办法明确告诉 Azure 不要使用 GPU?
    • 因此,该应用程序现在可以工作,但资源较少。我想部署的模型似乎太大而无法获得更好的服务计划等。
    猜你喜欢
    • 1970-01-01
    • 2017-08-02
    • 2019-06-20
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 2015-10-24
    • 2018-03-27
    • 2018-10-13
    相关资源
    最近更新 更多