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
=== added file 'README'
--- README 1970-01-01 00:00:00 +0000
+++ README 2012-01-10 18:44:23 +0000
@@ -0,0 +1,31 @@
1Juju charm python-moinmoin
2==========================
3
4:Author: Patrick Hetu <patrick@koumbit.org>
5
6Example deployment
7------------------
8
91. Setup your wiki specific parameters in mywiki.yaml like this::
10
11 mywiki:
12 wiki_name : "My MoinMoin wiki"
13 admin_name: "Admin"
14 languages: English French
15 xapian_search: True
16
172. Deployment with nginx::
18
19 juju bootstrap
20 juju deploy --config mywiki.yaml python-moinmoin
21 juju deploy nginx
22 juju add-relation nginx:reverseproxy python-moinmoin:website
23 juju expose nginx
24
253. Accessing your new moinmoin wiki should be ready at::
26
27 http://<nginx-machine-addr>/
28
29 To find out the public address of nginx, look for it in the output of the
30 `juju status` command.
31
032
=== modified file 'TODO.rst'
--- TODO.rst 2011-11-01 20:33:21 +0000
+++ TODO.rst 2012-01-10 18:44:23 +0000
@@ -1,10 +1,9 @@
1TODO1TODO
2====2====
33
4* Make it possible to share the data directory between units.4* Make it possible to share the data directory between units (nfs)
5* Configure the first user5
6* Configure the language6 * custom directories for users, data, cache, etc
7* Configure other options (frontpage, menus, theme, permissions, etc)7
8* Add relations to haproxy, nfs, etc8* Configure Gunicorn depending on the number of CPU available
9* Install and configure xapian9* logging + rsyslog
10
1110
=== removed directory 'apparmor'
=== modified file 'config.yaml'
--- config.yaml 2011-11-01 20:33:21 +0000
+++ config.yaml 2012-01-10 18:44:23 +0000
@@ -1,7 +1,26 @@
1options:1options:
2 wiki_name:2 wiki_name:
3 default: "My MoinMoin wiki"
3 type: string4 type: string
4 default: "moinmoin"5 description: The name of your wiki.
5 admin_name:6 admin_name:
6 type: string
7 default: "Admin"7 default: "Admin"
8 type: string
9 description: The wiki name of the admin user.
10 languages:
11 defaut: English
12 type: string
13 description: |
14 Languages to installed in a space-separated format.
15 For available languages see: http://moinmo.in/4ct10n/AttachFile/LanguageSetup?action=AttachFile
16 (write only the language name part)
17 xapian_search:
18 default: False
19 type: string
20 description: Set to True to enable the Xapian search engine.
21 extra_settings:
22 default: ""
23 type: string
24 description: |
25 For the list of available configuration options see: http://moinmo.in/HelpOnConfiguration.
26 Also, don't forget to starts your configuration lines with a 4 spaces indentation.
827
=== added file 'hooks/config-changed'
--- hooks/config-changed 1970-01-01 00:00:00 +0000
+++ hooks/config-changed 2012-01-10 18:44:23 +0000
@@ -0,0 +1,62 @@
1#!/bin/bash
2
3UNIT_NAME=`echo $JUJU_UNIT_NAME | cut -d/ -f1`
4
5WIKI_NAME=$(config-get wiki_name)
6ADMIN_NAME=$(config-get admin_name)
7LANGUAGES=$(config-get languages)
8XAPIAN_SETTINGS=$(config-get xapian_search)
9EXTRA_SETTINGS=$(config-get extra_settings)
10
11
12cat > /srv/${UNIT_NAME}/wikiconfig.py <<EOF
13# -*- coding: utf-8 -*-
14import os
15
16from MoinMoin.config import multiconfig, url_prefix_static
17
18class Config(multiconfig.DefaultConfig):
19 wikiconfig_dir = os.path.abspath(os.path.dirname(__file__))
20 instance_dir = wikiconfig_dir
21 data_dir = os.path.join(instance_dir, 'data', '') # path with trailing /
22 data_underlay_dir = os.path.join(instance_dir, 'underlay', '') # path with trailing /
23
24 sitename = u'$WIKI_NAME'
25 logo_string = u'<img src="%s/common/moinmoin.png" alt="MoinMoin Logo">' % url_prefix_static
26 superuser = [u"$ADMIN_NAME", ]
27 acl_rights_before = u"$ADMIN_NAME:read,write,delete,revert,admin"
28
29 page_front_page = u"FrontPage"
30 navi_bar = [
31 u'%(page_front_page)s',
32 u'RecentChanges',
33 u'FindPage',
34 u'HelpContents',
35 ]
36 xapian_search = ${XAPIAN_SETTINGS}
37 xapian_stemming = ${XAPIAN_SETTINGS}
38
39${EXTRA_SETTINGS}
40EOF
41
42
43if [ "$XAPIAN_SETTINGS" == "True" ] ; then
44 if [ ! -e /srv/${UNIT_NAME}/xapian_is_initialized ] ; then
45 moin --config-dir=/srv/${UNIT_NAME}/ index build --mode=add
46 touch /srv/${UNIT_NAME}/xapian_is_initialized
47 else
48 moin --config-dir=/srv/${UNIT_NAME}/ index build --mode=rebuild
49 fi
50fi
51
52cd /srv/${UNIT_NAME}/
53
54for lang in $LANGUAGES; do
55 python -m MoinMoin.packages i ./underlay/pages/LanguageSetup/attachments/${lang}--all_pages.zip
56done
57
58chown www-data /srv/${UNIT_NAME}/ -R
59chmod g+rw /srv/${UNIT_NAME}/ -R
60
61/etc/init.d/gunicorn start
62/etc/init.d/gunicorn reload
063
=== modified file 'hooks/install'
--- hooks/install 2011-11-01 20:33:21 +0000
+++ hooks/install 2012-01-10 18:44:23 +0000
@@ -1,93 +1,105 @@
1#!/bin/bash1#!/bin/bash
22
3UNIT_NAME=`echo $JUJU_UNIT_NAME | cut -d/ -f1`
4
3WIKI_NAME=$(config-get wiki_name)5WIKI_NAME=$(config-get wiki_name)
4ADMIN_NAME=$(config-get admin_name)6ADMIN_NAME=$(config-get admin_name)
57
6apt-get install -y python-moinmoin fckeditor python-flup nginx gunicorn unzip --no-install-recommends8apt-get install -y python-moinmoin fckeditor python-flup gunicorn python-eventlet unzip python-openid python-xapian python-xappy --no-install-recommends
79
8mkdir -p /srv/moinmoin_site/run10# MoinMoin's command line script 'moin' check there first
911# and we don't want that
10cp -r /usr/share/moin/data /usr/share/moin/underlay /srv/moinmoin_site/12rm /etc/moin/farmconfig.py
11cp -r /usr/share/moin/htdocs /srv/moinmoin_site/moin_static13
1214mkdir -p /srv/${UNIT_NAME}/run
13cat > /srv/moinmoin_site/wsgi.py << EOF15mkdir -p /srv/${UNIT_NAME}/logs
16
17cp -r /usr/share/moin/data /usr/share/moin/underlay /srv/${UNIT_NAME}/
18cp -r /usr/share/moin/htdocs /srv/${UNIT_NAME}/moin_static
19
20cat > /srv/${UNIT_NAME}/wsgi.py << EOF
21import sys
22sys.path.insert(0, '/srv/${UNIT_NAME}/')
23
14from MoinMoin.web.serving import make_application24from MoinMoin.web.serving import make_application
15from MoinMoin import log25from MoinMoin import log
1626
17application = make_application()27log.load_config('/srv/${UNIT_NAME}/logging.conf')
18EOF28
1929
20cat > /srv/moinmoin_site/wikiconfig.py <<EOF30application = make_application(shared='/srv/${UNIT_NAME}/moin_static')
21# -*- coding: utf-8 -*-31EOF
22import os32
23from MoinMoin.config import multiconfig, url_prefix_static33cat > /srv/${UNIT_NAME}/logging.conf << EOF
24class Config(multiconfig.DefaultConfig):34[DEFAULT]
25 wikiconfig_dir = os.path.abspath(os.path.dirname(__file__))35# Logfile to create.
26 instance_dir = wikiconfig_dir36# Make sure the running moin process has create/write rights there.
27 data_dir = os.path.join(instance_dir, 'data', '') # path with trailing /37logfile=/srv/${UNIT_NAME}/logs/moinmoin.log
28 data_underlay_dir = os.path.join(instance_dir, 'underlay', '') # path with trailing /38
29 url_prefix_static = '/moin_static'39# Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
30 sitename = u'$WIKI_NAME'40loglevel=INFO
31 logo_string = u'<img src="%s/common/moinmoin.png" alt="MoinMoin Logo">' % url_prefix_static41
32 superuser = [u"$ADMIN_NAME", ]42[loggers]
33 acl_rights_before = u"$ADMIN_NAME:read,write,delete,revert,admin"43keys=root
34 navi_bar = [44
35 u'%(page_front_page)s',45[handlers]
36 u'RecentChanges',46keys=logfile
37 u'FindPage',47
38 u'HelpContents',48[formatters]
39 ]49keys=logfile
40 theme_default = 'modern'50
41 language_default = 'en'51[logger_root]
42 page_front_page = u"FrontPage"52level=%(loglevel)s
43 page_category_regex = ur'(?P<all>Category(?P<key>(?!Template)\S+))'53handlers=logfile
44 page_dict_regex = ur'(?P<all>(?P<key>\S+)Dict)'54
45 page_group_regex = ur'(?P<all>(?P<key>\S+)Group)'55[handler_logfile]
46 page_template_regex = ur'(?P<all>(?P<key>\S+)Template)'56class=FileHandler
47 show_hosts = 157formatter=logfile
48EOF58level=%(loglevel)s
4959args=('%(logfile)s', 'at')
50cat > /etc/init/moinmoin_site.conf <<EOF60
51start on (net-device-up61[formatter_logfile]
52 and local-filesystems62format=%(levelname)s %(asctime)s %(name)s:%(lineno)d %(message)s
53 and runlevel [2345])63datefmt=
54stop on runlevel [!2345]64class=logging.Formatter
5565EOF
56respawn66
5767# find a free port from 80
58exec 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-data68# FIXME: but what about closed services?
59EOF69
6070PORT=8080
61rm /etc/nginx/sites-enabled/default71quit=0
6272
63cat > /etc/nginx/sites-enabled/moinmoin.conf << EOF73while [ "$quit" -ne 1 ]; do
64server {74 netstat -na | grep 'tcp' | grep 'LISTEN' | awk '{print $4}' | cut -d: -f2 | grep $PORT >> /dev/null
65 listen 80; ## listen for ipv4; this line is default and implied75 if [ $? -ne 0 ]
66 listen [::]:80 default ipv6only=on; ## listen for ipv676 then
6777 quit=1
68 root /srv/moinmoin_site;78 else
6979 PORT=`expr $PORT + 1`
70 location / {80 fi
71 proxy_pass http://unix:/srv/moinmoin_site/run/moinmoin_site_gunicorn:;81done
72 proxy_set_header Host \$host;82
73 proxy_set_header X-Real-IP \$remote_addr;83cat > /etc/gunicorn.d/${UNIT_NAME}.conf <<EOF
74 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;84CONFIG = {
75 }85 'mode': 'wsgi',
7686 'environment': {
77 location /moin_static {87 'PYTHONPATH': '/srv/${UNIT_NAME}/',
78 root /srv/moinmoin_site/;88 },
79 autoindex off;89 'working_dir': '/srv/${UNIT_NAME}/',
80 expires 1M;90 'user': 'www-data',
81 }91 'group': 'www-data',
92 'args': (
93 '--name=${UNIT_NAME}_wiki',
94 '--worker-class=eventlet',
95 '--bind=0.0.0.0:${PORT}',
96 '--workers=2',
97 '--log-file=/srv/${UNIT_NAME}/logs/gunicorn.log',
98 '--timeout=300',
99 'wsgi',
100 ),
82}101}
83EOF102EOF
84103
85chown www-data /srv/moinmoin_site/ -R104
86105open-port $PORT/tcp
87cd /srv/moinmoin_site/
88su -c "python -m MoinMoin.packages i ./underlay/pages/LanguageSetup/attachments/English--all_pages.zip" www-data
89
90start moinmoin_site
91/etc/init.d/nginx start
92
93open-port 80
94106
=== modified file 'revision'
--- revision 2011-11-01 20:33:21 +0000
+++ revision 2012-01-10 18:44:23 +0000
@@ -1,1 +1,1 @@
1415

Subscribers

People subscribed via source and target branches

to all changes: