OpenSolaris SMF Django Daemon Script
This is the manifest for being able to start django daemons via django-admin. A sample instance ('signet') is included.
- fcgi
- smf
- fastcgi
- opensolaris
- osol
- scgi
- ajp
This is the manifest for being able to start django daemons via django-admin. A sample instance ('signet') is included.
This recipe uses a modified version of Robin Dunn's fcgi.py module that adapts fcgi to wsgi and lets you run Django under mod_fcgid. One good thing about mod_fcgid is that it does all process management for you, which makes this setup quite straightforward. Also, since Robin's module works both in a cgi and fcgi context, switching a django site between cgi and fastcgi is a one-liner in the apache config, without any changes to python code or django config. CGI may be handy for development, since it loads all code (including changed code) on every request, yet lets you work in an environment that resembles production. Apache configuration examples are found in the comment at the beginning of the python module.
This is a basic view for a FastCGI authorizer against the Django auth. The idea is to return either a blank response with REMOTE_USER set on success, a forbidden response for failure, or a redirect to a login page when no user is logged in. I use this view for a Trac instance running on the same (lighttpd) server as Django. lighttpd is set up to use Django as a FastCGI authorizer (using snippet 1149) for the Trac URLs instead of using basic/digest HTTP authentication, so Trac has the same users as Django.
I use this as the FastCGI script for authorizers with lighttpd (though I guess it should work with little change on any other webserver supporting FastCGI). I point it to the same Django project/settings as the normal responder script. As I use it to gate access to pages not served by Django, I can include those non-Django URLs in the main urls.py, connected to special authorizer view functions (in another snippet). The two key parts of the script, compared to the equivalent one for Django in the normal FastCGI Responder role, are: 1. Pass the FCGI_AUTHORIZER as the role to WSGIServer 2. Generate a PATH_INFO variable from the REQUEST_URI (FastCGI authorizers aren't given PATH_INFO, but Django needs that to match against the URLconf.)
This is a simple rc script, suitable for starting a FastCGI daemon on FreeBSD. Simply copy this into /usr/local/etc/rc.d , change all references to "signet" to the name of your app, mark it executable and modify /etc/rc.conf accordingly.
5 snippets posted so far.