【问题标题】:Succeeded in Deploying Flask app at Azure, but app does not work upon opening website成功在 Azure 上部署 Flask 应用程序,但应用程序在打开网站时无法运行
【发布时间】:2019-11-15 02:30:25
【问题描述】:

我在将烧瓶应用程序部署到 azure 时遇到问题。我目前正在通过github进行部署,并且部署成功。但是在打开网站时,它给了我错误。主要是这个(查看应用程序日志):

 2019-11-15T02:22:03.098959319Z /opt/startup/startup.sh: 23:
  /opt/startup/startup.sh: gunicorn --bind=0.0.0.0 --timeout: not found

还有这个:

通过 github_0_a04a1362 的容器好消息没有响应端口:8000 上的 HTTP ping,站点启动失败。查看容器日志进行调试。

我的入口点是 gunicorn --bind=0.0.0.0 --timeout 600 run:app

And my code is

这是因为我的烧瓶结构吗?

任何帮助都会很棒!我真的被困在这上面了。

再次非常感谢您!希望大家有一个美好的一天。

【问题讨论】:

  • 请从 github 中删除您的令牌和机密。它在服务器上运行什么端口,你试图访问什么端口?
  • 谢谢斯里坎特!我已从 github 中删除了令牌。我真的不知道,我只是通过 github 上的 azure 部署它。你认为我需要一个 web.config 来部署 Azure 应用程序吗?我在这方面真的很新。
  • 您的网络访问网址是什么?默认情况下,flask 应用程序在端口 5000 上运行。如果你想要不同的端口,你应该在 app.run 中明确指定
  • @AlbertSugianto 那么你解决了你的问题吗?我查看了您的代码并尝试测试您的烧瓶结构,我确定没有在app.run() 中写入指定端口就可以,因为gunicorn 默认端口是8000,如果您启动gunicorn 的应用程序。但是根据你的错误信息,查看你的requirements.txt,如果你没有手动添加的话,requirements.txt里面好像有gunicorn的记录。所以这个错误意味着没有找到gunicorn命令,因为它没有安装,我认为这是关键。
  • 嗨@PeterPan 非常感谢您的回复。我已按照您的建议将 gunicorn 放入我的 requrements.txt 中,但仍然出现此错误:用法:main.py [-h] [--auth_host_name AUTH_HOST_NAME][--noauth_local_webserver] [-- auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]][--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] main.py: error: unrecognized arguments: run --host 0.0.0.0 --port 8000

标签: python azure flask


【解决方案1】:

原来是python中的shebang,linux需要识别py文件

#!/usr/bin/env python3 
# ^ is the shebang, not a comment 

from flaskapp import app

if __name__ == '__main__':
    app.run(host='0.0.0.0',port="8400",debug=True)
    #app.run(host='172.17.0.1',port="3306",debug=True)


【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2020-10-08
    • 2020-08-18
    • 2015-03-27
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多