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