Merge lp:~xaav/launchpad/wiki into lp:launchpad

Proposed by xaav
Status: Work in progress
Proposed branch: lp:~xaav/launchpad/wiki
Merge into: lp:launchpad
Diff against target: 113 lines (+103/-0)
2 files modified
scripts/start-wikkid.py (+100/-0)
scripts/stop-wikkid.py (+3/-0)
To merge this branch: bzr merge lp:~xaav/launchpad/wiki
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+63634@code.launchpad.net

Description of the change

Currently a work in progress.

Will provide wiki support for Launchpad.

See http://dev.launchpad.net/LEP/Wiki for implementation details.

TODO:

- Serve from more than one branch
- Set code branch to serve from

Bugs that must be fixed before wikkid is used: https://bugs.launchpad.net/wikkid/+bugs?field.tag=lp-required

To post a comment you must log in.
lp:~xaav/launchpad/wiki updated
13162. By xaav

renamed scripts

13163. By xaav

Imported paste.httpserver

13164. By xaav

adjusted start and stop wikkid.

Unmerged revisions

13164. By xaav

adjusted start and stop wikkid.

13163. By xaav

Imported paste.httpserver

13162. By xaav

renamed scripts

13161. By xaav

linked bug

13160. By xaav

Committed changes

13159. By xaav

Added wikkid start and stop scripts.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'scripts/start-wikkid.py'
2--- scripts/start-wikkid.py 1970-01-01 00:00:00 +0000
3+++ scripts/start-wikkid.py 2011-06-07 16:52:40 +0000
4@@ -0,0 +1,100 @@
5+#! /usr/bin/python
6+# -*- coding: utf-8 -*-
7+#
8+# Copyright (C) 2010 Wikkid Developers.
9+#
10+# This software is licensed under the GNU Affero General Public License
11+# version 3 (see the file LICENSE).
12+
13+"""The server class for the wiki."""
14+
15+try:
16+ import _wikkid_path
17+except ImportError:
18+ # Not running from a branch.
19+ pass
20+
21+import logging
22+import optparse
23+import sys
24+
25+from paste import httpserver
26+
27+from bzrlib.workingtree import WorkingTree
28+
29+from wikkid import version
30+from wikkid.app import WikkidApp
31+from wikkid.context import (
32+ DEFAULT_FORMAT,
33+ DEFAULT_HOST,
34+ DEFAULT_PORT,
35+ ExecutionContext,
36+ )
37+from wikkid.filestore.bzr import FileStore
38+from wikkid.user.bzr import LocalBazaarUserMiddleware
39+
40+from canonical.config import config
41+
42+
43+def setup_logging():
44+ """Set up a logger sending to stderr."""
45+ handler = logging.StreamHandler(sys.stderr)
46+ fmt = '%(asctime)s %(levelname)-7s %(message)s'
47+ formatter = logging.Formatter(
48+ fmt=fmt, datefmt="%Y-%m-%d %H:%M:%S")
49+ handler.setFormatter(formatter)
50+ root = logging.getLogger()
51+ root.addHandler(handler)
52+
53+#TODO: Use paste.httpserver
54+
55+
56+def main(args):
57+
58+ LISTEN_HOST = config.wiki.listen_host
59+ LISTEN_PORT = config.wiki.port
60+ THREADPOOL_WORKERS = 10
61+
62+ execution_context = ExecutionContext(
63+ host=LISTEN_HOST,
64+ port=LISTEN_PORT,
65+ default_format=options.default_format)
66+
67+
68+ setup_logging()
69+ logger = logging.getLogger('wikkid')
70+ logger.setLevel(logging.INFO)
71+
72+ working_tree = WorkingTree.open(branch)
73+ logger.info('Using: %s', working_tree)
74+ filestore = FileStore(working_tree)
75+
76+ app = WikkidApp(filestore=filestore)
77+ app = LocalBazaarUserMiddleware(app, working_tree.branch)
78+
79+ try:
80+ httpserver.serve(
81+ app, host=LISTEN_HOST, port=LISTEN_PORT,
82+ threadpool_workers=THREADPOOL_WORKERS,
83+ threadpool_options={
84+ # Kill threads after 300 seconds. This is insanely high, but
85+ # lower enough than the default (1800 seconds!) that evidence
86+ # suggests it will be hit occasionally, and there's very little
87+ # chance of it having negative consequences.
88+ 'kill_thread_limit': 300,
89+ # Check for threads that should be killed every 10 requests. The
90+ # default is every 100, which is easily long enough for things to
91+ # gum up completely in between checks.
92+ 'hung_check_period': 10,
93+ })
94+ finally:
95+ log.info('Shutdown.')
96+ try:
97+ os.remove(pidfile)
98+ except OSError:
99+ pass
100+
101+
102+
103+if __name__ == "__main__":
104+ main(sys.argv)
105
106=== added file 'scripts/stop-wikkid.py'
107--- scripts/stop-wikkid.py 1970-01-01 00:00:00 +0000
108+++ scripts/stop-wikkid.py 2011-06-07 16:52:40 +0000
109@@ -0,0 +1,3 @@
110+#!/usr/bin/python -S
111+
112+print "Not implemented"
113\ No newline at end of file