Commits

Anonymous committed 6eacdf4

change doc

Comments (0)

Files changed (3)

 .swp
 .installed.cfg
 _build
+build
+dist
         run shell use bpython
                 
 
-      runcgi:
+      runfcgi:
         run application use flup
         you can choose these arguments:
         protocol :   scgi, fcgi or ajp
 
         --no-ipython
 
+Deploy use fastcgi
+------------------------
+To start your server,run the `runfcgi` command::
+
+    ./manage.py runfcgi [options]
+
+Select your preferred protocol by using the ``protocol=<protocol_name>`` option
+with ``./manage.py runfcgi`` -- where ``<protocol_name>`` may be one of: ``scgi`` (the default),
+``fcgi`` or ``ajp``. 
+
+Running a threaded server on a TCP port::
+
+    ./manage.py runfcgi method=threaded host=127.0.0.1 port=3033
+
+Running a preforked server on a Unix domain socket::
+
+    ./manage.py runfcgi method=prefork socket=/home/user/mysite.sock pidfile=flask.pid
+
+Run without daemonizing (backgrounding) the process (good for debugging)::
+
+    ./manage.py runfcgi daemonize=false socket=/tmp/mysite.sock maxrequests=1
+
+Stopping the FastCGI daemon
+`````````````````````````````
+
+If you have the process running in the foreground, it's easy enough to stop it:
+Simply hitting ``Ctrl-C`` will stop and quit the FastCGI server. However, when
+you're dealing with background processes, you'll need to resort to the Unix
+``kill`` command.
+
+If you specify the ``pidfile`` option to `runfcgi`, you can kill the
+running FastCGI daemon like this::
+
+    kill `cat $PIDFILE`
+
+...where ``$PIDFILE`` is the ``pidfile`` you specified.
+
+Setup Nginx
+``````````````````````````````
+Run the application using fastcgi daemonize mode ,like this::
+
+    python manage.py runfcgi --protocol=fcgi -p 7777  --daemonize --pidfile=/var/run/flaskapp.pid
+
+but you would rather use an init.d scripts to execute above commands ,
+then you can configure the nginx like this ::
+
+      upstream flaskapp {
+         server 127.0.0.1:7777;
+         }
+
+      server {
+      listen 8080;
+      server_name  127.0.0.0;
+
+
+      location / {
+        fastcgi_pass  flaskapp;
+        fastcgi_param REQUEST_METHOD    $request_method;
+        fastcgi_param QUERY_STRING      $query_string;
+        fastcgi_param CONTENT_TYPE      $content_type;
+        fastcgi_param CONTENT_LENGTH    $content_length;
+        fastcgi_param SERVER_ADDR       $server_addr;
+        fastcgi_param SERVER_PORT       $server_port;
+        fastcgi_param SERVER_NAME       $server_name;
+        fastcgi_param SERVER_PROTOCOL   $server_protocol;
+        fastcgi_param PATH_INFO         $fastcgi_script_name;
+        fastcgi_param REMOTE_ADDR       $remote_addr;
+        fastcgi_param REMOTE_PORT       $remote_port;
+        fastcgi_pass_header Authorization;
+        fastcgi_intercept_errors off;
+      }

flaskext/actions.py

 import sys,os
 from werkzeug import script
 
-def runcgi(application, before_daemon=None):
+def runfcgi(application, before_daemon=None):
     def action( hostname            =   ('h', ''),
                 port                =   ('p', 3001),
                 protocol            =   'scgi',
     def __init__(self, application):
         self.application = application
         self._actions = {
-                'runcgi'    :   runcgi(application),
+                'runfcgi'    :   runfcgi(application),
                 'shell'     :   script.make_shell(lambda: {"app": application},
                                     "Interactive Flask Shell"),
                 'runserver' :   script.make_runserver(lambda: application,