I have a functioning Django application on the local development server, however when deyploying it to an Apache + mod_wsgi setup the urls don't seem to get resolved correctly, i.e. the url module within an installed app cannot be loaded. I have been debugging this for quite some time now and would greatly appreciate some help.
There is actually no real error message in the apache logs, so there might be some infinite loop going on, but I wouldn't know where or why. After a long time the request ends with error code 500 and log message: "Daemon process deadlock timer expired, stopping process 'Tianjin'." I found the url import to be the problem through painful debugging and print statements and realizing this is the point where the application gets stuck. The stack is something like this, where import(name) never returns with name being "Tianjin.urls".
import_module [__init__.py:37]
urlconf_module [urlresolvers.py:396]
url_patterns [urlresolvers.py:402]
resolve [urlresolvers.py:366]
get_response [base.py:119]
My setup:
- Linux 4.2.0-27-generic #32-Ubuntu SMP x86_64 GNU/Linux
- Apache/2.4.12 (Ubuntu) Server MPM: forked threaded
- Python 2.7 in a virtual environment called env in the project folder
- mod_wsgi-4.4.21, compiled from sources
- Django 1.8.5
Directory structure in /home/TianjinAdmin/:
-IRIS
-env
-..
-Tianjin
- __init__.py
- celery.py
- settins.py
- urls.py
- wsgi.py
-TianjinUI
- __init__.py
- admin.py
- models.py
- tests.py
- urls.py
- views.py
-TianjinBE
- ...
- manage.py
Apache Virtual Host Configuration:
<VirtualHost *:80>
ServerAdmin bla@gmail.com
DocumentRoot /var/www/html
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/TianjinAdmin/IRIS/templates/TianjinUI/app
<Directory /home/TianjinAdmin/IRIS/templates/TianjinUI/app>
Require all granted
</Directory>
<Directory /home/TianjinAdmin/IRIS/Tianjin>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess Tianjin python-path=/home/TianjinAdmin/IRIS:/home/TianjinAdmin/IRIS/env/lib/python2.7/site-packages processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup Tianjin
WSGIScriptAlias / /home/TianjinAdmin/IRIS/Tianjin/wsgi.py
</VirtualHost>
Tianjin/wsgi.py
import os, sys
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Tianjin.settings")
#tried with and without the following two lines
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
print >> sys.stderr, sys.path
application = get_wsgi_application()
relevant Content of Tianjin/settings.py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#'kombu.transport.django',
'kombu.transport.django.KombuAppConfig',
'djcelery',
'TianjinBE',
'TianjinUI',
)
ROOT_URLCONF = 'Tianjin.urls'
Tianjin/urls.py
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^ui/', include('TianjinUI.urls')),
url(r'^oauth/', include('TianjinBE.urls')),
url(r'^admin/', include(admin.site.urls)),
]