使用Jelastic云部署Python\Django

kpbwa7wx  于 2022-12-14  发布在  Go
关注(0)|答案(1)|浏览(146)

我尝试在Jelastic Cloud上部署应用程序但未成功。我收到一条一般错误消息“RuntimeError:populate()是不可重入的”,并且我不被允许修改“django/apps/registry.py“以获得更多细节。manage.py
我的项目结构:

Webroot
  |_venv
  |_ROOT
    |_wsgi.py
    |_requirements.txt
    |_monprojet
       |_monapplication
         |_ ...
       |_manage.py
       |_monprojet
         |_settings.py
         |_ ...

Error.log

Thu Sep 08 18:53:08.292973 2022] [wsgi:error] [pid 19457] [remote 10.*:20006] mod_wsgi (pid=19457): Failed to exec Python script file '/var/www/webroot/ROOT/wsgi.py'.
[Thu Sep 08 18:53:08.293121 2022] [wsgi:error] [pid 19457] [remote 10.*:20006] mod_wsgi (pid=19457): Exception occurred processing WSGI script '/var/www/webroot/ROOT/wsgi.py'.
[Thu Sep 08 18:53:08.293885 2022] [wsgi:error] [pid 19457] [remote 10.*:20006] Traceback (most recent call last):
[Thu Sep 08 18:53:08.294049 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]   File "/var/www/webroot/ROOT/wsgi.py", line 15, in <module>
[Thu Sep 08 18:53:08.294083 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]     application = get_wsgi_application()
[Thu Sep 08 18:53:08.294136 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]   File "/opt/jelastic-python310/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Sep 08 18:53:08.294169 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]     django.setup(set_prefix=False)
[Thu Sep 08 18:53:08.294254 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]   File "/opt/jelastic-python310/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
[Thu Sep 08 18:53:08.294281 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]     apps.populate(settings.INSTALLED_APPS)
[Thu Sep 08 18:53:08.294415 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]   File "/opt/jelastic-python310/lib/python3.10/site-packages/django/apps/registry.py", line 83, in populate
[Thu Sep 08 18:53:08.294490 2022] [wsgi:error] [pid 19457] [remote 10.*:20006]     raise RuntimeError("populate() isn't reentrant")
[Thu Sep 08 18:53:08.294790 2022] [wsgi:error] [pid 19457] [remote 10.*:20006] RuntimeError: populate() isn't reentrant

WSGI.PY

virtenv = os.path.expanduser('~') + '/venv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
    if sys.version.split(' ')[0].split('.')[0] == '3':
        exec(compile(open(virtualenv, "rb").read(), virtualenv, 'exec'), dict(__file__=virtualenv))
    else:
        execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
    pass
sys.path.append(os.path.expanduser('~'))
sys.path.append(os.path.expanduser('~') + '/ROOT/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ROOT.monprojet.monprojet.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

settings.py 摘录:

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'monapplication',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'monprojet.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'ROOT.wsgi.application'

谢谢

0s0u357o

0s0u357o1#

您应该在您的设置中设置WSGI_APPLICATION = 'monprojet.wsgi.application',即与URL conf相同级别的路径。

相关问题