Merge lp:~patrick-hetu/charms/oneiric/python-moinmoin/trunk into lp:charms/oneiric/python-moinmoin

Proposed by Patrick Hetu
Status: Merged
Merged at revision: 2
Proposed branch: lp:~patrick-hetu/charms/oneiric/python-moinmoin/trunk
Merge into: lp:charms/oneiric/python-moinmoin
Diff against target: 356 lines (+215/-92)
6 files modified
README (+31/-0)
TODO.rst (+6/-7)
config.yaml (+21/-2)
hooks/config-changed (+62/-0)
hooks/install (+94/-82)
revision (+1/-1)
To merge this branch: bzr merge lp:~patrick-hetu/charms/oneiric/python-moinmoin/trunk
Reviewer Review Type Date Requested Status
Clint Byrum (community) Approve
Review via email: mp+88100@code.launchpad.net

Description of the change

Added Documentation, Configurations and Gunicorn as wsgi server.

To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Looks great patrick, thanks so much for the ongoing contributions!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'README'
2--- README 1970-01-01 00:00:00 +0000
3+++ README 2012-01-10 18:44:23 +0000
4@@ -0,0 +1,31 @@
5+Juju charm python-moinmoin
6+==========================
7+
8+:Author: Patrick Hetu <patrick@koumbit.org>
9+
10+Example deployment
11+------------------
12+
13+1. Setup your wiki specific parameters in mywiki.yaml like this::
14+
15+ mywiki:
16+ wiki_name : "My MoinMoin wiki"
17+ admin_name: "Admin"
18+ languages: English French
19+ xapian_search: True
20+
21+2. Deployment with nginx::
22+
23+ juju bootstrap
24+ juju deploy --config mywiki.yaml python-moinmoin
25+ juju deploy nginx
26+ juju add-relation nginx:reverseproxy python-moinmoin:website
27+ juju expose nginx
28+
29+3. Accessing your new moinmoin wiki should be ready at::
30+
31+ http://<nginx-machine-addr>/
32+
33+ To find out the public address of nginx, look for it in the output of the
34+ `juju status` command.
35+
36
37=== modified file 'TODO.rst'
38--- TODO.rst 2011-11-01 20:33:21 +0000
39+++ TODO.rst 2012-01-10 18:44:23 +0000
40@@ -1,10 +1,9 @@
41 TODO
42 ====
43
44-* Make it possible to share the data directory between units.
45-* Configure the first user
46-* Configure the language
47-* Configure other options (frontpage, menus, theme, permissions, etc)
48-* Add relations to haproxy, nfs, etc
49-* Install and configure xapian
50-
51+* Make it possible to share the data directory between units (nfs)
52+
53+ * custom directories for users, data, cache, etc
54+
55+* Configure Gunicorn depending on the number of CPU available
56+* logging + rsyslog
57
58=== removed directory 'apparmor'
59=== modified file 'config.yaml'
60--- config.yaml 2011-11-01 20:33:21 +0000
61+++ config.yaml 2012-01-10 18:44:23 +0000
62@@ -1,7 +1,26 @@
63 options:
64 wiki_name:
65+ default: "My MoinMoin wiki"
66 type: string
67- default: "moinmoin"
68+ description: The name of your wiki.
69 admin_name:
70- type: string
71 default: "Admin"
72+ type: string
73+ description: The wiki name of the admin user.
74+ languages:
75+ defaut: English
76+ type: string
77+ description: |
78+ Languages to installed in a space-separated format.
79+ For available languages see: http://moinmo.in/4ct10n/AttachFile/LanguageSetup?action=AttachFile
80+ (write only the language name part)
81+ xapian_search:
82+ default: False
83+ type: string
84+ description: Set to True to enable the Xapian search engine.
85+ extra_settings:
86+ default: ""
87+ type: string
88+ description: |
89+ For the list of available configuration options see: http://moinmo.in/HelpOnConfiguration.
90+ Also, don't forget to starts your configuration lines with a 4 spaces indentation.
91
92=== added file 'hooks/config-changed'
93--- hooks/config-changed 1970-01-01 00:00:00 +0000
94+++ hooks/config-changed 2012-01-10 18:44:23 +0000
95@@ -0,0 +1,62 @@
96+#!/bin/bash
97+
98+UNIT_NAME=`echo $JUJU_UNIT_NAME | cut -d/ -f1`
99+
100+WIKI_NAME=$(config-get wiki_name)
101+ADMIN_NAME=$(config-get admin_name)
102+LANGUAGES=$(config-get languages)
103+XAPIAN_SETTINGS=$(config-get xapian_search)
104+EXTRA_SETTINGS=$(config-get extra_settings)
105+
106+
107+cat > /srv/${UNIT_NAME}/wikiconfig.py <<EOF
108+# -*- coding: utf-8 -*-
109+import os
110+
111+from MoinMoin.config import multiconfig, url_prefix_static
112+
113+class Config(multiconfig.DefaultConfig):
114+ wikiconfig_dir = os.path.abspath(os.path.dirname(__file__))
115+ instance_dir = wikiconfig_dir
116+ data_dir = os.path.join(instance_dir, 'data', '') # path with trailing /
117+ data_underlay_dir = os.path.join(instance_dir, 'underlay', '') # path with trailing /
118+
119+ sitename = u'$WIKI_NAME'
120+ logo_string = u'<img src="%s/common/moinmoin.png" alt="MoinMoin Logo">' % url_prefix_static
121+ superuser = [u"$ADMIN_NAME", ]
122+ acl_rights_before = u"$ADMIN_NAME:read,write,delete,revert,admin"
123+
124+ page_front_page = u"FrontPage"
125+ navi_bar = [
126+ u'%(page_front_page)s',
127+ u'RecentChanges',
128+ u'FindPage',
129+ u'HelpContents',
130+ ]
131+ xapian_search = ${XAPIAN_SETTINGS}
132+ xapian_stemming = ${XAPIAN_SETTINGS}
133+
134+${EXTRA_SETTINGS}
135+EOF
136+
137+
138+if [ "$XAPIAN_SETTINGS" == "True" ] ; then
139+ if [ ! -e /srv/${UNIT_NAME}/xapian_is_initialized ] ; then
140+ moin --config-dir=/srv/${UNIT_NAME}/ index build --mode=add
141+ touch /srv/${UNIT_NAME}/xapian_is_initialized
142+ else
143+ moin --config-dir=/srv/${UNIT_NAME}/ index build --mode=rebuild
144+ fi
145+fi
146+
147+cd /srv/${UNIT_NAME}/
148+
149+for lang in $LANGUAGES; do
150+ python -m MoinMoin.packages i ./underlay/pages/LanguageSetup/attachments/${lang}--all_pages.zip
151+done
152+
153+chown www-data /srv/${UNIT_NAME}/ -R
154+chmod g+rw /srv/${UNIT_NAME}/ -R
155+
156+/etc/init.d/gunicorn start
157+/etc/init.d/gunicorn reload
158
159=== modified file 'hooks/install'
160--- hooks/install 2011-11-01 20:33:21 +0000
161+++ hooks/install 2012-01-10 18:44:23 +0000
162@@ -1,93 +1,105 @@
163 #!/bin/bash
164
165+UNIT_NAME=`echo $JUJU_UNIT_NAME | cut -d/ -f1`
166+
167 WIKI_NAME=$(config-get wiki_name)
168 ADMIN_NAME=$(config-get admin_name)
169
170-apt-get install -y python-moinmoin fckeditor python-flup nginx gunicorn unzip --no-install-recommends
171-
172-mkdir -p /srv/moinmoin_site/run
173-
174-cp -r /usr/share/moin/data /usr/share/moin/underlay /srv/moinmoin_site/
175-cp -r /usr/share/moin/htdocs /srv/moinmoin_site/moin_static
176-
177-cat > /srv/moinmoin_site/wsgi.py << EOF
178+apt-get install -y python-moinmoin fckeditor python-flup gunicorn python-eventlet unzip python-openid python-xapian python-xappy --no-install-recommends
179+
180+# MoinMoin's command line script 'moin' check there first
181+# and we don't want that
182+rm /etc/moin/farmconfig.py
183+
184+mkdir -p /srv/${UNIT_NAME}/run
185+mkdir -p /srv/${UNIT_NAME}/logs
186+
187+cp -r /usr/share/moin/data /usr/share/moin/underlay /srv/${UNIT_NAME}/
188+cp -r /usr/share/moin/htdocs /srv/${UNIT_NAME}/moin_static
189+
190+cat > /srv/${UNIT_NAME}/wsgi.py << EOF
191+import sys
192+sys.path.insert(0, '/srv/${UNIT_NAME}/')
193+
194 from MoinMoin.web.serving import make_application
195 from MoinMoin import log
196
197-application = make_application()
198-EOF
199-
200-cat > /srv/moinmoin_site/wikiconfig.py <<EOF
201-# -*- coding: utf-8 -*-
202-import os
203-from MoinMoin.config import multiconfig, url_prefix_static
204-class Config(multiconfig.DefaultConfig):
205- wikiconfig_dir = os.path.abspath(os.path.dirname(__file__))
206- instance_dir = wikiconfig_dir
207- data_dir = os.path.join(instance_dir, 'data', '') # path with trailing /
208- data_underlay_dir = os.path.join(instance_dir, 'underlay', '') # path with trailing /
209- url_prefix_static = '/moin_static'
210- sitename = u'$WIKI_NAME'
211- logo_string = u'<img src="%s/common/moinmoin.png" alt="MoinMoin Logo">' % url_prefix_static
212- superuser = [u"$ADMIN_NAME", ]
213- acl_rights_before = u"$ADMIN_NAME:read,write,delete,revert,admin"
214- navi_bar = [
215- u'%(page_front_page)s',
216- u'RecentChanges',
217- u'FindPage',
218- u'HelpContents',
219- ]
220- theme_default = 'modern'
221- language_default = 'en'
222- page_front_page = u"FrontPage"
223- page_category_regex = ur'(?P<all>Category(?P<key>(?!Template)\S+))'
224- page_dict_regex = ur'(?P<all>(?P<key>\S+)Dict)'
225- page_group_regex = ur'(?P<all>(?P<key>\S+)Group)'
226- page_template_regex = ur'(?P<all>(?P<key>\S+)Template)'
227- show_hosts = 1
228-EOF
229-
230-cat > /etc/init/moinmoin_site.conf <<EOF
231-start on (net-device-up
232- and local-filesystems
233- and runlevel [2345])
234-stop on runlevel [!2345]
235-
236-respawn
237-
238-exec su -c "cd /srv/moinmoin_site/; /usr/bin/gunicorn wsgi --workers 2 --bind=unix:/srv/moinmoin_site/run/moinmoin_site_gunicorn --pid=/srv/moinmoin_site/run/moinmoin_site_gunicorn.pid" www-data
239-EOF
240-
241-rm /etc/nginx/sites-enabled/default
242-
243-cat > /etc/nginx/sites-enabled/moinmoin.conf << EOF
244-server {
245- listen 80; ## listen for ipv4; this line is default and implied
246- listen [::]:80 default ipv6only=on; ## listen for ipv6
247-
248- root /srv/moinmoin_site;
249-
250- location / {
251- proxy_pass http://unix:/srv/moinmoin_site/run/moinmoin_site_gunicorn:;
252- proxy_set_header Host \$host;
253- proxy_set_header X-Real-IP \$remote_addr;
254- proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
255- }
256-
257- location /moin_static {
258- root /srv/moinmoin_site/;
259- autoindex off;
260- expires 1M;
261- }
262+log.load_config('/srv/${UNIT_NAME}/logging.conf')
263+
264+
265+application = make_application(shared='/srv/${UNIT_NAME}/moin_static')
266+EOF
267+
268+cat > /srv/${UNIT_NAME}/logging.conf << EOF
269+[DEFAULT]
270+# Logfile to create.
271+# Make sure the running moin process has create/write rights there.
272+logfile=/srv/${UNIT_NAME}/logs/moinmoin.log
273+
274+# Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
275+loglevel=INFO
276+
277+[loggers]
278+keys=root
279+
280+[handlers]
281+keys=logfile
282+
283+[formatters]
284+keys=logfile
285+
286+[logger_root]
287+level=%(loglevel)s
288+handlers=logfile
289+
290+[handler_logfile]
291+class=FileHandler
292+formatter=logfile
293+level=%(loglevel)s
294+args=('%(logfile)s', 'at')
295+
296+[formatter_logfile]
297+format=%(levelname)s %(asctime)s %(name)s:%(lineno)d %(message)s
298+datefmt=
299+class=logging.Formatter
300+EOF
301+
302+# find a free port from 80
303+# FIXME: but what about closed services?
304+
305+PORT=8080
306+quit=0
307+
308+while [ "$quit" -ne 1 ]; do
309+ netstat -na | grep 'tcp' | grep 'LISTEN' | awk '{print $4}' | cut -d: -f2 | grep $PORT >> /dev/null
310+ if [ $? -ne 0 ]
311+ then
312+ quit=1
313+ else
314+ PORT=`expr $PORT + 1`
315+ fi
316+done
317+
318+cat > /etc/gunicorn.d/${UNIT_NAME}.conf <<EOF
319+CONFIG = {
320+ 'mode': 'wsgi',
321+ 'environment': {
322+ 'PYTHONPATH': '/srv/${UNIT_NAME}/',
323+ },
324+ 'working_dir': '/srv/${UNIT_NAME}/',
325+ 'user': 'www-data',
326+ 'group': 'www-data',
327+ 'args': (
328+ '--name=${UNIT_NAME}_wiki',
329+ '--worker-class=eventlet',
330+ '--bind=0.0.0.0:${PORT}',
331+ '--workers=2',
332+ '--log-file=/srv/${UNIT_NAME}/logs/gunicorn.log',
333+ '--timeout=300',
334+ 'wsgi',
335+ ),
336 }
337 EOF
338
339-chown www-data /srv/moinmoin_site/ -R
340-
341-cd /srv/moinmoin_site/
342-su -c "python -m MoinMoin.packages i ./underlay/pages/LanguageSetup/attachments/English--all_pages.zip" www-data
343-
344-start moinmoin_site
345-/etc/init.d/nginx start
346-
347-open-port 80
348+
349+open-port $PORT/tcp
350
351=== modified file 'revision'
352--- revision 2011-11-01 20:33:21 +0000
353+++ revision 2012-01-10 18:44:23 +0000
354@@ -1,1 +1,1 @@
355-4
356+5

Subscribers

People subscribed via source and target branches

to all changes: