damned-lies r1133 - in branches/djamnedlies: . docs



Author: claudep
Date: Thu Nov  6 21:20:27 2008
New Revision: 1133
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1133&view=rev

Log:
2008-11-06  Claude Paroz  <claude 2xlibre net>

	* docs/scgi-sample-init-script.txt:
	* README: Added some hints about running Django as CGI.

Added:
   branches/djamnedlies/docs/scgi-sample-init-script.txt
Modified:
   branches/djamnedlies/ChangeLog
   branches/djamnedlies/README

Modified: branches/djamnedlies/README
==============================================================================
--- branches/djamnedlies/README	(original)
+++ branches/djamnedlies/README	Thu Nov  6 21:20:27 2008
@@ -59,3 +59,12 @@
 mode: http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
 (sql-mode="ANSI_QUOTES" in my.cnf) but it can be dangerous for other
 applications.
+
+Running as CGI
+==============
+
+If you don't won't to setup Django with mod_python, there is a tutorial
+on the Django Wiki:
+http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/
+
+You'll also file a sample init script in the /docs directory.

Added: branches/djamnedlies/docs/scgi-sample-init-script.txt
==============================================================================
--- (empty file)
+++ branches/djamnedlies/docs/scgi-sample-init-script.txt	Thu Nov  6 21:20:27 2008
@@ -0,0 +1,105 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          FastCGI servers for Django
+# Required-Start:    networking
+# Required-Stop:     networking
+# Default-Start:     2 3 4 5
+# Default-Stop:      S 0 1 6
+# Short-Description: Start FastCGI servers with Django.
+# Description:       Django, in order to operate with FastCGI, must be started
+#                    in a very specific way with manage.py. This must be done
+#                    for each DJango web server that has to run.
+### END INIT INFO
+#
+# Author:  Guillermo Fernandez Castellanos
+#          <guillermo.fernandez.castellanos AT gmail.com>.
+#
+# Version: @(#)fastcgi 0.1 11-Jan-2007 guillermo.fernandez.castellanos AT gmail.com
+#
+
+#### SERVER SPECIFIC CONFIGURATION
+DJANGO_SITES="djamnedlies"
+SITES_PATH=/var/www
+RUNFILES_PATH=$SITES_PATH/run
+HOST=127.0.0.1
+PORT_START=3000
+RUN_AS=user
+#### DO NOT CHANGE ANYTHING AFTER THIS LINE!
+
+set -e
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DESC="FastCGI servers"
+NAME=$0
+SCRIPTNAME=/etc/init.d/$NAME
+
+#
+#       Function that starts the daemon/service.
+#
+d_start()
+{
+    # Starting all Django FastCGI processes
+    PORT=$PORT_START
+    for SITE in $DJANGO_SITES
+    do
+        echo -n ", $SITE"
+        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
+            echo -n " already running"
+        else
+            start-stop-daemon --start --quiet \
+                       --pidfile $RUNFILES_PATH/$SITE.pid \
+                       --chuid $RUN_AS --exec /usr/bin/env -- python \
+                       $SITES_PATH/$SITE/manage.py runfcgi method=threaded \
+                       protocol=scgi host=$HOST port=$PORT pidfile=$RUNFILES_PATH/$SITE.pid
+            chmod 400 $RUNFILES_PATH/$SITE.pid
+        fi
+        let "PORT = $PORT + 1"
+    done
+}
+
+#
+#       Function that stops the daemon/service.
+#
+d_stop() {
+    # Killing all Django FastCGI processes running
+    for SITE in $DJANGO_SITES
+    do
+        echo -n ", $SITE"
+        start-stop-daemon --stop --quiet --pidfile $RUNFILES_PATH/$SITE.pid \
+                          || echo -n " not running"
+        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
+           rm $RUNFILES_PATH/$SITE.pid
+        fi
+    done
+}
+
+ACTION="$1"
+case "$ACTION" in
+    start)
+        echo -n "Starting $DESC: $NAME"
+        d_start
+        echo "."
+        ;;
+
+    stop)
+        echo -n "Stopping $DESC: $NAME"
+        d_stop
+        echo "."
+        ;;
+
+    restart|force-reload)
+        echo -n "Restarting $DESC: $NAME"
+        d_stop
+        sleep 1
+        d_start
+        echo "."
+        ;;
+
+    *)
+        echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
+        exit 3
+        ;;
+esac
+
+exit 0
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]