简体   繁体   中英

Python\Django deployment with Jelastic cloud

i try to deploy an app on Jelastic cloud without success. I have a generic error message "RuntimeError: populate() isn't reentrant" and i'm not allowed to modify "django/apps/registry.py" for more details. This project run with manage.py

Structure of my project:

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 extract:

# 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'

Thanks

You should set WSGI_APPLICATION = 'monprojet.wsgi.application' in your settings, ie the same level path as URL conf.

Man, It's a nightmare now for Python distributions. I can't get an 2 years old env running correctly after little adjustments.. & I'm not speaking about config tweaks. I got a 500 for each single env I update.

  • platform is laggy as hell, can't even login smoothly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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