简体   繁体   English

将Django应用程序部署到Digital Ocean-Gunicorn错误

[英]Deploy a Django Application to Digital Ocean - Gunicorn Error

I'm trying to deploy my first app to digital ocean with help of this tutorial . 我正在尝试借助本教程将我的第一个应用程序部署到数字海洋。

When I try to run sudo supervisorctl restart [appname], I get the following error. 当我尝试运行sudo administratorctl restart [appname]时,出现以下错误。 (This is only a part of the error) (这只是错误的一部分)

     [2019-01-16 09:10:49 +0000] [2653] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/srimal/django_project/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
  File "/home/srimal/django_project/productUploader/shadesProductUploader/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/home/srimal/django_project/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/home/srimal/django_project/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/srimal/django_project/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/home/srimal/django_project/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/home/srimal/django_project/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'authSection'

My setup in the server is 我在服务器上的设置是

在此处输入图片说明

and the supervisor config file 和主管配置文件

#!/bin/sh
[program:productUploader]
command=/home/srimal/django_project/bin/gunicorn_start
user=srimal
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/srimal/logs/gunicorn-error.log

and the gunicorn_start file 和gunicorn_start文件

#!/bin/bash

NAME="productUploader"
DIR=/home/srimal/django_project
USER=srimal
GROUP=srimal
WORKERS=3
BIND=unix:/home/srimal/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=productUploader.shadesProductUploader.settings
DJANGO_WSGI_MODULE=productUploader.shadesProductUploader.wsgi
LOG_LEVEL=error

cd $DIR
source /home/srimal/django_project/bin/activate

export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH

exec /home/srimal/django_project/bin/gunicorn    ${DJANGO_WSGI_MODULE}:application \
 --name $NAME \
 --workers $WORKERS \
 --user=$USER \
 --group=$GROUP \
 --bind=$BIND \
 --log-level=$LOG_LEVEL \
 --log-file=-

What am I doing wrong? 我究竟做错了什么?

It seems as though the productUploader directory is a python package, based on the fact that you're passing it in the dotted path to DJANGO_SETTINGS_MODULE and DJANGO_WSGI_MODULE . 似乎productUploader目录是一个python软件包,基于以下事实:您将其以点路径传递给DJANGO_SETTINGS_MODULEDJANGO_WSGI_MODULE Thus you should also do the same for the apps in INSTALLED_APPS : 因此,您还应该对INSTALLED_APPS的应用执行相同的操作:

INSTALLED_APPS = [
    'productUploader.authSection',  # Use full path
    'productUploader.mainSection',  # Use full path
    'django.contrib.humanize',
    'django.contrib.admin', 
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles',
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM