Auto Start + Django

#1
Basically, I'd like to get Django working with LiteSpeed and I'm willing to pay for someone's help. I've already got Django working with LiteSpeed with the following external application configuration:

Code:
Name: Django
Address: UDS://home2/iaihmb/webapps/django/myproject.sock
Max Connections: 50
Initial Request Timeout (secs): 10
Retry Timeout (secs): 5
Everything else is set to its default value.

This is where you come in, I'd like to use auto start. After finding this post I added/changed the following:

Code:
Max Connections: 20
Autostart: Yes
Command: /home2/iaihmb/webapps/django/myproject/manage.py runfcgi method=threaded socket=~/webapps/django/myproject.sock
Back Log: I've tried 1, 50, and 100.
Instances: 1 (I've tried 1, 500, and 1000.)
Among other things I've also tried adding "daemonized=false" and removing "socket=~/webapps/django/myproject.sock" from the command but I always end up with the same error:

ExtConn timed out while processing.

If someone can help me with this problem today I'll donate $25 USD to their charity of choice or buy them something worth ~$25 USD from their Amazon wish list. :)
 
Last edited:

mistwang

LiteSpeed Staff
#2
Maybe manage.py does not work well, you need to create a file like below and start your app with that file, without any command line parameters.
Code:
#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/user/python")

# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
I copied the code from django documentation which let Apache spawn django process.
 
#3
I just tried that and it doesn't work and the same error is being logged. I've also tried this:

Code:
#!/usr/local/bin/python2.4

from os import environ
from sys import path

from django.core.handlers.wsgi import WSGIHandler
from fcgi import WSGIServer

path += [
	'/home2/iaihmb/lib/python2.4/',
	'/home2/iaihmb/webapps/django/',
]

environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

WSGIServer(WSGIHandler()).run()
Thanks for trying though. :)
 

mistwang

LiteSpeed Staff
#4
Is there anything in lsws/logs/error.log or lsws/logs/stderr.log, maybe you need to set some extra environment variables to make django happy.
 
#5
Unfortunately there isn't.

Debug logging is enabled and the control panel and error.log both show quite a few of these:

2007-05-27 13:05:42.073 [NOTICE] [70.125.68.240:1473-0#Django] ExtConn timed out while processing.
I'm fooling around with it now, maybe I'll get lucky. :)

Edit: I'm not sure if it's relevant but the UDS does get created.
 

mistwang

LiteSpeed Staff
#6
UDS socket is created by the server.
Is the python process running, maybe it dies immediately.
One way to trace it down is to use "strace" to trace the djyango process, command is like

Code:
strace -o strace.log <orignal FCGI command>
You probably cannot use this command directly in the App configuration, just create a wrapper shell script.
 
#7
Good catch, thanks! :D

write(2, "ImportError", 11) = 11
write(2, ": ", 2) = 2
write(2, "No module named django.core.serv"..., 43) = 43
write(2, "\n", 1)
Even though the location of the Django module was added to the PYTHONPATH in the script that you found in Django's documentation it didn't work until I added it to the environment bit in the external application's configuration.

Care to pick a charity or post the link to your Amazon wish list? :)
 
Top