Skip to content

Instantly share code, notes, and snippets.

@reidrac
Created February 13, 2011 21:19
Show Gist options
  • Save reidrac/825144 to your computer and use it in GitHub Desktop.
Save reidrac/825144 to your computer and use it in GitHub Desktop.
django fastcgi sig handler
#!/usr/bin/python
import sys, os
import signal
quit_requested = False
def intSigHandler(signal, frame):
quit_requested = True
signal.signal(signal.SIGINT, intSigHandler)
# 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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment