PDA

View Full Version : Djang and fcgi and mod_fcgid errors



Fernker
12-21-2011, 09:03 AM
Ok I'm exhausted with BlueHost right now and getting everything working with Python 2.7 (which I had to install the other day since 2.6 was pulled, thanks for that).

I got a Django app that was running in 2.6 running again in 2.7 on the server so I'm pretty sure that it isn't 2.7 causing these problems.


I've uploaded my app and everything appears to be working fine except for one thing, the photo uploader that I'm using (which is the core of the site). I'm using the stdimage2 Django app (a fork of stdimage) and it worked fine on the development server (Ubuntu 10.04). But it's having major problems at the moment and I'm looking for any possible ideas or inklings of things that I'm missing.

Here's the errors that are being printed out (this is with four pictures being sent as separate requests one after the other by the uploader):


[Wed Dec 21 09:47:03 2011] [warn] [client 128.187.97.6] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:03 2011] [error] [client 128.187.97.6] Premature end of script headers: mySite.fcgi, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:03 2011] [warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.
[Wed Dec 21 09:47:03 2011] [warn] [client 128.187.97.6] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:03 2011] [error] [client 128.187.97.6] Premature end of script headers: mySite.fcgi, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:04 2011] [warn] [client 128.187.97.6] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:04 2011] [error] [client 128.187.97.6] Premature end of script headers: mySite.fcgi, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:05 2011] [error] mod_fcgid: process /home3/fernsten/public_html/ffamily/gallery/mySite.fcgi(22492) exit(communication error), get unexpected signal 11


This is what my fcgi file looks like:



#!/home3/fernsten/local/Python-2.7/bin/python
import sys, os
print "sys.path is ", sys.path

#add a custom Python path and pray it works dddd
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7/site-packages")
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7")
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7/site-packages/flup-1.0.2-py2.7.egg")
sys.path.insert(0, "/home3/fernsten/django_projects")
sys.path.insert(0, "/home3/fernsten/django_projects/gallery")
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg")

os.chdir("/home3/fernsten/django_projects/gallery")

os.environ['DJANGO_SETTINGS_MODULE'] = "gallery.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")



And lastly here's the function where it dies:


if request.method == 'POST':
result = []
newform = Photo()
newform.image= request.FILES.get('file')
newform.album=Album.objects.get(pk=album_pk)
newform.save()
result.append({"name":"Uploaded image",
"size":newform.image.size,
"url":MEDIA_URL + newform.image.url,
"thumbnail_url": newform.image.url.replace(".",".thumbnail."),
"delete_url":'/backend/delete_img/' + str(newform.pk)+'/',
"delete_type":"POST",
})
response_data = simplejson.dumps(result)
return HttpResponse(response_data, mimetype='application/json')
return render_to_response('backend/upload_images.html',{'album_pk':album_pk},context_ instance=RequestContext(request))

I'm fairly certain it's happening in this area because when I do newform.save() stdimage2 does things in the background, such as renaming the uploaded picture and creating and naming a thumbnail. The image is being renamed but no thumbnail is being generated.


Any ideas would be awesome as this is getting quite annoying. Thanks!