First time here? Check out the FAQ!
1

Can't make ASKBOT work with uWSGI

I'm trying to run ASKBOT using uWSGI but I can't figure how. Everything looks right on the log, except this:

ImportError: No module named wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)

I already checked the related Questions here (including this one describing the .INI file) and other documentations on Django + uWSGI. As my server runs like a charm when using manage.py runserver I'm guessing this is some configuration I'm not getting right. Here it is my WSGI (which I imagine was generated by the ASKBOT installation, right?):

import os
import sys
import time
import traceback
import signal

current_directory = os.path.dirname(__file__)
parent_directory = os.path.dirname(current_directory)
module_name = os.path.basename(current_directory)

sys.path.append(parent_directory)
sys.path.append(current_directory)
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % module_name

from django.core.wsgi import get_wsgi_application
try:
    application = get_wsgi_application()
    print 'WSGI without exception'
except Exception:
    print 'handling WSGI exception'
    # Error loading applications
    if 'mod_wsgi' in sys.modules:
        traceback.print_exc()
        os.kill(os.getpid(), signal.SIGINT)
        time.sleep(2.5)

This file is in the same folder my settings.py and the askbot folder. I get essentially the same error if I execute uWSGI via --module file.wsgi or if I configure the whole .INI

Any help will be much appreciated.

Nigini A. Oliveira's avatar
111
Nigini A. Oliveira
asked 2018-08-15 19:29:43 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

I got it:

First I saw I should be executing the uWSGI with the option --wsgi-file and not --module. That got rid of the ImportError but presented a new unable to find "application" callable in file error.

To solve that, I found that the recommended .INI file in previous posts here was this:

 [uwsgi]
socket = /var/uwsgi/askbot.sock
user = www-data
chdir = <django project directory>          #directory that has settings.py file.
logto = /var/log/uwsgi/askbot.err
pidfile =  /var/uwsgi/askbot.pid
pythonpath = <parent of django project directory>
pythonpath = <django project directory>
virtualenv = <path to python virtual environment>
env = DJANGO_SETTINGS_MODULE=<project dir name>.settings
module = django.core.handlers.wsgi:WSGIHandler()
env = LC_ALL=en_US.UTF-8
threads = 1
workers = 4
master = true
max-requests = 1000
harakiri = 120
buffer-size = 24576

But I found in this Stack Overflow answer that the module configuration should be:

module = django.core.wsgi:get_wsgi_application()

It seems this is a change that happened in Django 1.6.

BTW: I'm using Python 2.7 and Django 1.8.19

Nigini A. Oliveira's avatar
111
Nigini A. Oliveira
answered 2018-08-17 13:58:41 -0500, updated 2018-08-17 14:15:14 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments