我有一个现有的 django 项目,我正在尝试将其部署到 Oracle 的云服务Application Container。
我按照Oracle 的指南执行此操作,但是本指南中缺少一些细节。具体来说,该指南引用了一个app.py文件,该文件似乎来自本指南。但我看不到如何在 django 项目中使用它。
我尝试替换对app.py的调用以使用 django 的manage.py或wsgi.py文件,但 Oracle 服务器仍然无法启动。Oracle 提供的服务器日志也无济于事,只告诉我正在安装 python 包。
ACCS[web.1]: Content of APP_HOME [ /u01/app/ ] dir
ACCS[web.1]: total 96
ACCS[web.1]: -rw-r----- 1 apaas apaas 28423 May 17 10:51 readme.html
ACCS[web.1]: -rw-r----- 1 apaas apaas 40960 May 17 10:51 db.sqlite3
ACCS[web.1]: -rw-r----- 1 apaas apaas 355 Sep 10 13:26 manage.py
ACCS[web.1]: -rw-r----- 1 apaas apaas 254 Sep 10 13:28 DjangoProject.pyproj.user
ACCS[web.1]: -rw-r----- 1 apaas apaas 6990 Sep 10 13:28 DjangoProject.pyproj
ACCS[web.1]: -rw-r----- 1 apaas apaas 186 Sep 12 11:24 manifest.json
ACCS[web.1]: drwxr-x--- 1 apaas apaas 10 Sep 13 03:42 obj
ACCS[web.1]: drwxr-x--- 1 apaas apaas 160 Sep 13 03:42 app
ACCS[web.1]: drwxr-x--- 1 apaas apaas 94 Sep 13 03:42 DjangoProject
ACCS[web.1]: drwxr-xr-x 1 apaas apaas 286 Sep 13 03:42 .
ACCS[web.1]: drwxr-xr-x 1 apaas apaas 46 Sep 13 03:42 ..
ACCS[web.1]: -rw-r----- 1 apaas apaas 290 Sep 13 2018 start.sh
ACCS[web.1]: -rw-r----- 1 apaas apaas 51 Sep 13 2018 requirements.txt
ACCS[web.1]: Application should listen on 0.0.0.0:$PORT [enabling app to listen on all interfaces on $PORT env variable]
ACCS[web.1]: Starting application with launch command [ sh ./start.sh ]
APP[web.1]: Collecting Django==1.11.15 (from -r ./requirements.txt (line 1))
APP[web.1]: Downloading https://files.pythonhosted.org/packages/f8/1c/31112c778b7a56ce18e3fff5e8915719fbe1cd3476c1eef557dddacfac8b/Django-1.11.15-py2.py3-none-any.whl (6.9MB)
APP[web.1]: Collecting pytz==2018.5 (from -r ./requirements.txt (line 2))
APP[web.1]: Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
APP[web.1]: Collecting setuptools==39.0.1 (from -r ./requirements.txt (line 3))
APP[web.1]: Downloading https://files.pythonhosted.org/packages/20/d7/04a0b689d3035143e2ff288f4b9ee4bf6ed80585cc121c90bfd85a1a8c2e/setuptools-39.0.1-py2.py3-none-any.whl (569kB)
APP[web.1]: Installing collected packages: pytz, Django, setuptools
APP[web.1]: Successfully installed Django-1.11.15 pytz-2018.5 setuptools-39.0.1
APP[web.1]: You are using pip version 9.0.1, however version 18.0 is available.
APP[web.1]: You should consider upgrading via the 'pip install --upgrade pip' command.
在制作我的start.sh文件时,我也 从本指南中找到了用途。
#!/bin/sh
pip --no-cache-dir install -r ./requirements.txt -t modules
export PYTHONPATH=$PYTHONPATH:modules
python manage.py runserver
我已经联系了 Oracle 的支持,但他们也找不到解决方案。他们的建议是在我尝试过的wsgi.py文件中包含服务器使用的 PORT 变量。
import os
import sys
from django.core.management import call_command
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DjangoMedmin.settings")
application = get_wsgi_application()
PORT_NUMBER = int(os.environ.get('PORT', 8084))
call_command('runserver', '0.0.0.0:'+str(PORT_NUMBER))
我错过了什么?是否可以让 django 与 Oracle 合作?