changeset 4266:65af466e6df0

Combined deployment script for CGI/FCGI
author Florian Krupicka <florian.krupicka@googlemail.com>
date Tue, 05 Aug 2008 22:31:52 +0200
parents dc253f097867
children 1e21b63603f7
files MoinMoin/web/cgi_interface.py wiki/server/moin.cgi wiki/server/moin.fcg
diffstat 3 files changed, 57 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/web/cgi_interface.py	Tue Aug 05 22:31:52 2008 +0200
@@ -0,0 +1,52 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - CGI/FCGI interface
+
+    @copyright: 2008 MoinMoin:FlorianKrupicka
+    @license: GNU GPL, see COPYING for details.
+"""
+import optparse
+
+from MoinMoin.web.serving import make_application
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
+
+def run():
+    parser = optparse.OptionParser()
+    parser.add_option("-d", "--debug", action="store_true",
+                      help="Enable debug mode of server (show tracebacks)")
+    parser.add_option("-c", "--config-dir", dest="config_dir", metavar="DIR",
+                      help=("Path to the directory containing the wiki "
+                            "configuration files. Default: current directory"))
+    parser.add_option("-p", "--port", dest="port", type="int",
+                      help="Set the port to listen on. Act as CGI/FCGI script otherwise")
+    parser.add_option("-i", "--interface", dest="interface",
+                      help=("Set the interface/socket to listen on. If starts "
+                            "with '/' or './' it is interpreted as a path "
+                            "to a unix socket. Default: localhost"))
+    parser.set_default('interface', 'localhost')
+
+    try:
+        from flup.server.fcgi import WSGIServer
+    except ImportError:
+        # TODO: insert some fallback here
+        pass
+
+    options, args = parser.parse_args()
+
+    logging.debug('Options: %r', options)
+
+    kwargs = {}
+    if options.port:
+        kwargs['bindAddress'] = (options.interface, options.port)
+    elif options.interface.startswith('/') or \
+            options.interface.startswith('./'):
+        kwargs['bindAddress'] = options.interface
+
+    app = make_application()
+    WSGIServer(app, **kwargs).run()
+
+if __name__ == '__main__':
+    run()
--- a/wiki/server/moin.cgi	Tue Aug 05 22:25:28 2008 +0200
+++ b/wiki/server/moin.cgi	Tue Aug 05 22:31:52 2008 +0200
@@ -1,10 +1,11 @@
 #!/usr/bin/env python
 # -*- coding: iso-8859-1 -*-
 """
-    MoinMoin - CGI Driver Script
+    MoinMoin - CGI/FCGI Driver script
 
     @copyright: 2000-2005 by Juergen Hermann <jh@web.de>,
-                2008 by MoinMoin:ThomasWaldmann
+                2008 by MoinMoin:ThomasWaldmann,
+                2008 by MoinMoin:FlorianKrupicka
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -30,24 +31,6 @@
 #from MoinMoin import log
 #log.load_config('/path/to/logging_configuration_file')
 
-# Debug mode - show detailed error reports
-#os.environ['MOIN_DEBUG'] = '1'
-
-
-from MoinMoin.server.server_cgi import CgiConfig, run
-
-class Config(CgiConfig):
-    # Server name - used to create .prof files
-    name = 'moin'
+from MoinMoin.web.cgi_interface import run
 
-    # Properties
-    # Allow overriding any request property by the value defined in
-    # this dict e.g properties = {'script_name': '/mywiki'}.
-    ## properties = {}
-
-    # Hotshot profile (default commented)
-    ## hotshotProfile = name + '.prof'
-
-
-run(Config)
-
+run()
--- a/wiki/server/moin.fcg	Tue Aug 05 22:25:28 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - FastCGI Driver Script
-    
-    @copyright: 2008 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-
-import sys, os
-
-# a) Configuration of Python's code search path
-#    If you already have set up the PYTHONPATH environment variable for the
-#    stuff you see below, you don't need to do a1) and a2).
-
-# a1) Path of the directory where the MoinMoin code package is located.
-#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
-#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
-
-# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
-#     See wiki/config/... for some sample config files.
-#sys.path.insert(0, '/path/to/wikiconfigdir')
-#sys.path.insert(0, '/path/to/farmconfigdir')
-
-# b) Configuration of moin's logging
-#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
-#    You also don't need this if you are happy with the builtin defaults.
-#    See wiki/config/logging/... for some sample config files.
-#from MoinMoin import log
-#log.load_config('/path/to/logging_configuration_file')
-
-# Debug mode - show detailed error reports
-#os.environ['MOIN_DEBUG'] = '1'
-
-
-from MoinMoin.server.server_fastcgi import FastCgiConfig, run
-
-class Config(FastCgiConfig):
-    properties = {}
-    # properties = {'script_name': '/'} # use this instead of the line above if your wiki runs under "/" url
-
-    # for backlog, we use a default of 5. if the listen(backlog) call crashes for you, try a smaller value!
-    # backlog = 1
-
-run(Config)
-