LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > CGI/Perl/Python > Auto Start + Django

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2007, 06:42 AM
iaihmb iaihmb is offline
New Member
 
Join Date: May 2007
Posts: 6
Default Auto Start + Django

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 by iaihmb; 05-27-2007 at 06:45 AM..
Reply With Quote
  #2  
Old 05-27-2007, 08:18 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
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.
Reply With Quote
  #3  
Old 05-27-2007, 09:04 AM
iaihmb iaihmb is offline
New Member
 
Join Date: May 2007
Posts: 6
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.
Reply With Quote
  #4  
Old 05-27-2007, 12:47 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
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.
Reply With Quote
  #5  
Old 05-27-2007, 12:52 PM
iaihmb iaihmb is offline
New Member
 
Join Date: May 2007
Posts: 6
Unfortunately there isn't.

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

Quote:
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.
Reply With Quote
  #6  
Old 05-27-2007, 04:29 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
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.
Reply With Quote
  #7  
Old 05-28-2007, 07:31 AM
iaihmb iaihmb is offline
New Member
 
Join Date: May 2007
Posts: 6
Good catch, thanks!

Quote:
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?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:32 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.