【问题标题】:Django app with mysql support not working when deployed to GCP部署到 GCP 时,支持 mysql 的 Django 应用程序无法正常工作
【发布时间】:2019-06-17 10:12:55
【问题描述】:

我正在尝试使用 MySQL 作为数据库创建示例 Django 应用程序,当我尝试在 GCP 上部署的同一应用程序出现 500 错误时,它在本地工作正常。 我在 GCP 中创建了 sql server 并使用了相同的设置

它无法找到gunicorn,但我已在requirments.txt 中指定了所有这些。

2019-01-19 07:42:57 default[20190119t130429]  "GET /admin HTTP/1.1" 500
2019-01-19 07:42:58 default[20190119t130429]  /bin/sh: 1: exec: gunicorn: not found
2019-01-23 17:41:21 default[20190119t130429]  "GET /admin HTTP/1.1" 500
2019-01-23 17:41:22 default[20190119t130429]  /bin/sh: 1: exec: gunicorn: not found
2019-01-23 18:36:00 default[20190123t235752]  "GET /admin HTTP/1.1" 500
2019-01-23 18:36:00 default[20190123t235752]  /bin/sh: 1: exec: gunicorn: not found
2019-01-23 18:36:01 default[20190123t235752]  "GET /favicon.ico HTTP/1.1" 500
2019-01-23 18:36:02 default[20190123t235752]  /bin/sh: 1: exec: gunicorn: not found
2019-01-23 18:36:20 default[20190123t235752]  "GET /admin HTTP/1.1" 500
2019-01-23 18:36:20 default[20190123t235752]  /bin/sh: 1: exec: gunicorn: not found
2019-01-23 18:36:21 default[20190123t235752]  "GET /favicon.ico HTTP/1.1" 500
2019-01-23 18:36:21 default[20190123t235752]  /bin/sh: 1: exec: gunicorn: not found
**app.yaml**

runtime: python37
entrypoint: gunicorn -b :$PORT sqlreco.wsgi
#threadsafe: yes

handlers:
- url: /images
  static_dir: static/images
  http_headers:
    Access-Control-Allow-Origin: '*'

runtime_config:
 python_version: 3


**requirnaments.txt**

Django==2.1.5
djangorestframework==3.9.1
mysql==0.0.2
mysqlclient==1.4.1
pytz==2018.9
gunicorn==19.8.1

【问题讨论】:

    标签: python mysql django google-app-engine google-cloud-platform


    【解决方案1】:

    基于此错误:

    ModuleNotFoundError: No module named 'main'
    

    您的应用程序似乎没有main.py 文件。如果您没有指定自定义入口点,则需要在此文件中添加一个名为 app 的变量,该变量对应于您的应用程序。

    对于 Django,您可以在 main.py 中执行类似的操作:

    from mysite.wsgi import application as app
    

    mysite 是 Django 应用所在目录的名称。

    【讨论】:

    • 已经完成了那个错误是旧的我已经更新了有问题的日志,删除了旧的日志
    • 您能否在问题中包含您的app.yaml 和您的requirements.txt
    • 添加了 app.yaml 和 requirements.txt
    • 您的文件的字面意思是requirnaments.txt吗?那里有一个错字,它可以解释为什么没有安装gunicorn
    猜你喜欢
    • 2018-12-18
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-20
    • 2019-01-17
    • 1970-01-01
    相关资源
    最近更新 更多