errors running on mod wsgi

86 views
Skip to first unread message

satyaakam goswami

unread,
Jan 6, 2013, 4:58:01 AM1/6/13
to fossa...@googlegroups.com
following is the batucada,wsgi file 

import os
import site
from datetime import datetime

# Remember when mod_wsgi loaded this file so we can track it in nagios.
wsgi_loaded = datetime.now()

# Tell celery that we're using Django.
os.environ['CELERY_LOADER'] = 'django'

# Tell WSGI where to look for settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

# Add the zamboni dir to the python path so we can import manage.
wsgidir = os.path.dirname(__file__)
site.addsitedir(os.path.abspath(os.path.join(wsgidir, '/home/dingo/.virtualenvs/fossacademy/lib/python2.6/site-packages')))
site.addsitedir(os.path.abspath(os.path.join(wsgidir, '/home/dingo/.virtualenvs/fossacademy/src')))

# manage adds /apps, /lib, and /vendor to the Python path.
import manage

import django.conf
import django.core.handlers.wsgi
import django.core.management
import django.utils

# Do validate and activate translations like using `./manage.py runserver`.
django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
utility = django.core.management.ManagementUtility()
command = utility.fetch_command('runserver')
command.validate()

# This is what mod_wsgi runs.
django_app = django.core.handlers.wsgi.WSGIHandler()

def application(env, start_response):
    env['wsgi.loaded'] = wsgi_loaded
    env['datetime'] = str(datetime.now())
    return django_app(env, start_response)

# Uncomment this to figure out what's going on with the mod_wsgi environment.
# def application(env, start_response):
#     start_response('200 OK', [('Content-Type', 'text/plain')])
#     return '\n'.join('%r: %r' % item for item in sorted(env.items()))


this is giving the following errors in the log of apache , i am pretty sure it has something to do with loading the environment variables from virtualenv can any anyone figure it out ?


mod_wsgi (pid=11920): Target WSGI script '/home/dingo/fossacademy/lernanta/wsgi/batucada.wsgi' cannot be loaded as Python module.
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76] mod_wsgi (pid=11920): Exception occurred processing WSGI script '/home/dingo/fossacademy/lernanta/wsgi/batucada.wsgi'.
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76] Traceback (most recent call last):
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76]   File "/home/dingo/fossacademy/lernanta/wsgi/batucada.wsgi", line 20, in <module>
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76]     import manage
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76] ImportError: No module named manage



Kantesh Raj

unread,
Jan 6, 2013, 6:51:34 AM1/6/13
to fossa...@googlegroups.com
Hi,

mod_wsgi (pid=11920): Target WSGI script '/home/dingo/fossacademy/lernanta/wsgi/batucada.wsgi' cannot be loaded as Python module.
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76] mod_wsgi (pid=11920): Exception occurred processing WSGI script '/home/dingo/fossacademy/lernanta/wsgi/batucada.wsgi'.
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76] Traceback (most recent call last):
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76]   File "/home/dingo/fossacademy/lernanta/wsgi/batucada.wsgi", line 20, in <module>
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76]     import manage
[Sun Jan 06 09:53:34 2013] [error] [client 119.82.82.76] ImportError: No module named manage
 
Append the path of folder containing manage.py and settings.py by following code:

import sys
sys.path.append('enter_path_of_directory')

Kantesh Raj

unread,
Jan 6, 2013, 6:57:09 AM1/6/13
to fossa...@googlegroups.com

import sys
sys.path.append('enter_path_of_directory')

this will work fine:
import sys
sys.path.append('/home/dingo/fossacademy/lernanta/')



--
Kantesh Raj

Kantesh Raj

unread,
Jan 6, 2013, 7:22:25 AM1/6/13
to fossa...@googlegroups.com
Hi,

Try WSGI attached with this mail.
batucada.wsgi

satyaakam goswami

unread,
Jan 6, 2013, 8:29:20 AM1/6/13
to fossa...@googlegroups.com
On Sun, Jan 6, 2013 at 5:52 PM, Kantesh Raj <kante...@gmail.com> wrote:
Hi,

Try WSGI attached with this mail.


now i am getting this error also i fixed group to www-data for wsgi file

[Sun Jan 06 13:24:15 2013] [error] [client 119.82.82.76] Premature end of script headers: batucada.wsgi
/home/dingo/.virtualenvs/fossacademy/bin/python: can't open file 'mod_wsgi': [Errno 2] No such file or directory
[Sun Jan 06 13:24:21 2013] [error] [client 119.82.82.76] Premature end of script headers: batucada.wsgi

-Satya


satyaakam goswami

unread,
Jan 6, 2013, 8:32:35 AM1/6/13
to fossa...@googlegroups.com

now i am getting this error also i fixed group to www-data for wsgi file

[Sun Jan 06 13:24:15 2013] [error] [client 119.82.82.76] Premature end of script headers: batucada.wsgi
/home/dingo/.virtualenvs/fossacademy/bin/python: can't open file 'mod_wsgi': [Errno 2] No such file or directory
[Sun Jan 06 13:24:21 2013] [error] [client 119.82.82.76] Premature end of script headers: batucada.wsgi


this is what FAQ says 

Q: Why am I seeing the error message 'premature end of script headers' in the Apache error logs.

A: If using daemon mode, this is a symptom of the mod_wsgi daemon process crashing when handling a request. You would probably also see the message 'segmentation fault'. See answer for question about 'segmentation fault' above.

This error message can also occur where you haven't configured Apache correctly and your WSGI script file is being executed as a CGI script instead.

-Satya





satyaakam goswami

unread,
Jan 6, 2013, 2:13:35 PM1/6/13
to fossa...@googlegroups.com
instead.


hmm just ran a test check fossacademy.org , we need to just fix the env variable errors , things on the apache side are just fine

satyaakam goswami

unread,
Jan 7, 2013, 1:16:04 PM1/7/13
to fossa...@googlegroups.com
On Mon, Jan 7, 2013 at 12:43 AM, satyaakam goswami <saty...@gmail.com> wrote:
instead.


hmm just ran a test check fossacademy.org , we need to just fix the env variable errors , things on the apache side are just fine


[Mon Jan 07 18:13:27 2013] [info] mod_wsgi (pid=16028): Initializing Python.
[Mon Jan 07 18:13:27 2013] [info] mod_wsgi (pid=16028): Attach interpreter ''.
[Mon Jan 07 18:13:27 2013] [info] mod_wsgi (pid=16029): Initializing Python.
[Mon Jan 07 18:13:28 2013] [info] mod_wsgi (pid=16029): Attach interpreter ''.
/home/dingo/.virtualenvs/fossacademy/bin/python: can't open file 'mod_wsgi': [Errno 2] No such file or directory
/home/dingo/.virtualenvs/fossacademy/bin/python: can't open file 'mod_wsgi': [Errno 2] No such file or directory
 
this is what i see in error log of apache , why is it trying to look for mod_wsgi in the virtualenv ?

-Satya



Reply all
Reply to author
Forward
0 new messages