python - 部署到 GCP 时,支持 mysql 的 Django 应用程序无法正常工作
问题描述
我正在尝试使用 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
解决方案
基于此错误:
ModuleNotFoundError: No module named 'main'
您的应用程序似乎没有main.py
文件。如果您没有指定自定义入口点,则需要让这个文件带有一个名为的变量,该变量app
对应于您的应用程序。
对于 Django,您可能只需要在以下位置执行以下操作main.py
:
from mysite.wsgi import application as app
mysite
您的 Django 应用程序所在的目录的名称在哪里。
推荐阅读
- python - 代码在编辑器上运行良好,但在 Code Wars 中出现 EOF 错误
- r - R Studio ScriptRunConfig 中的 Azure-ML-R SDK 在已弃用的估算器替换后无法识别函数错误
- node.js - 如何开始构建跨平台应用程序?
- oracle - 在 Oracle 的区间范围分区上创建索引
- javascript - 在 Vue 中调用“this”会返回 Window
- excel - 为新项目设置自动添加里程碑
- reactjs - 类型定义似乎在 react-hook-form 7 中不起作用
- notepad++ - 复制行的一部分并用分隔符将其添加到行尾
- flutter - 颤振音频管理器onEvents不起作用
- android - 在颤振中,只有在文本表单字段中有一些值时,如何使按钮可点击?