annotate wiki/server/moin.fcg @ 2971:7fb3bc39c7b1

moin.fcg: add example for running under / url (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 05 Jan 2008 20:58:40 +0100
parents 78d745b57730
children d6fb846dc73c
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 #!/usr/bin/env python
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4 MoinMoin - FastCGI Driver Script
1946
412b50bb3740 add some MoinMoin.server refactoring TODOs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1172
diff changeset
5
412b50bb3740 add some MoinMoin.server refactoring TODOs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1172
diff changeset
6 TODO: this should be refactored so it uses MoinMoin.server package
412b50bb3740 add some MoinMoin.server refactoring TODOs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1172
diff changeset
7 (see how Twisted, WSGI and Standalone use it)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 @copyright: 2004-2005 by Oliver Graf <ograf@bitart.de>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 # System path configuration
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 import sys
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 # Path of the directory where wikiconfig.py is located.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 # YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 sys.path.insert(0, '/path/to/wikiconfig')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 # Path to MoinMoin package, needed if you installed with --prefix=PREFIX
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 # or if you did not use setup.py.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 ## sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 # Path of the directory where farmconfig is located (if different).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 ## sys.path.insert(0, '/path/to/farmconfig')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27
49
cf52f97a5857 merge moin--main--1.3--patch-928
Nir Soffer <nirs@freeshell.org>
parents: 0
diff changeset
28 # Debug mode - show detailed error reports
cf52f97a5857 merge moin--main--1.3--patch-928
Nir Soffer <nirs@freeshell.org>
parents: 0
diff changeset
29 ## import os
cf52f97a5857 merge moin--main--1.3--patch-928
Nir Soffer <nirs@freeshell.org>
parents: 0
diff changeset
30 ## os.environ['MOIN_DEBUG'] = '1'
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31
1171
28120c8c1b6b thfcgi: updated CHANGES, use unlimited lifetime by default
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1170
diff changeset
32 # how many requests shall be handled by a moin fcgi process before it dies,
28120c8c1b6b thfcgi: updated CHANGES, use unlimited lifetime by default
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1170
diff changeset
33 # -1 mean "unlimited lifetime":
28120c8c1b6b thfcgi: updated CHANGES, use unlimited lifetime by default
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1170
diff changeset
34 max_requests = -1
1170
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
35
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
36 # how many threads to use (1 means use only main program, non-threaded)
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
37 max_threads = 5
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
38
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
39 # backlog, use in socket.listen(backlog) call
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
40 backlog = 5
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43 # Code ------------------------------------------------------------------
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 # Do not touch unless you know what you are doing!
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 # TODO: move to server package?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 # Set threads flag, so other code can use proper locking
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 from MoinMoin import config
1170
a8aca1c131a9 thfcgi: limit max. number of requests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1169
diff changeset
50 config.use_threads = max_threads > 1
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 del config
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52
2418
78d745b57730 fixing missing changes to example scripts for server and request renaming
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1946
diff changeset
53 from MoinMoin.request import request_fcgi
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 from MoinMoin.support import thfcgi
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 def handle_request(req, env, form):
2418
78d745b57730 fixing missing changes to example scripts for server and request renaming
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1946
diff changeset
57 request = request_fcgi.Request(req, env, form)
2971
7fb3bc39c7b1 moin.fcg: add example for running under / url (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2418
diff changeset
58 # use this instead of the line above if your wiki runs under "/" url:
7fb3bc39c7b1 moin.fcg: add example for running under / url (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2418
diff changeset
59 #request = request_fcgi.Request(req, env, form, properties={'script_name': '/'})
7fb3bc39c7b1 moin.fcg: add example for running under / url (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2418
diff changeset
60
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 request.run()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 if __name__ == '__main__':
1172
8f8f594e7647 thfcgi: use max_requests as param name, it's more clear
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1171
diff changeset
64 fcg = thfcgi.FCGI(handle_request, max_requests=max_requests, backlog=backlog, max_threads=max_threads)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
65 fcg.run()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66