Merge lp:~jjo/ubuntu-api-website/add-api-website-relations into lp:ubuntu-api-website

Proposed by JuanJo Ciarlante on 2013-09-26
Status: Needs review
Proposed branch: lp:~jjo/ubuntu-api-website/add-api-website-relations
Merge into: lp:ubuntu-api-website
Diff against target: 629 lines (+540/-0) (has conflicts)
15 files modified
README (+40/-0)
config.yaml (+108/-0)
hooks/api-website-relation-joined (+9/-0)
hooks/common.sh (+83/-0)
hooks/config-changed (+56/-0)
hooks/db-relation-changed (+45/-0)
hooks/install (+76/-0)
hooks/nrpe-external-master-relation-changed (+40/-0)
hooks/start (+5/-0)
hooks/stop (+8/-0)
hooks/website-cache-relation-joined (+7/-0)
hooks/wsgi-file-relation-changed (+22/-0)
metadata.yaml (+19/-0)
revision (+1/-0)
scripts/check_status_file.sh (+21/-0)
Conflict adding file README.  Moved existing file to README.moved.
To merge this branch: bzr merge lp:~jjo/ubuntu-api-website/add-api-website-relations
Reviewer Review Type Date Requested Status
Ubuntu API Website Developers 2013-09-26 Pending
Review via email: mp+187871@code.launchpad.net
To post a comment you must log in.
5. By JuanJo Ciarlante on 2013-09-26

[jjo, r=mhall119] Add a basic api-website-relation-{joined,changed} hook, need as per provides (for reverseproxy-like FE services in-front) - requires setting {hostname,port} properly

6. By JuanJo Ciarlante on 2013-09-30

[jjo,r=???] add nagios_context config, change NAGIOS_HOSTNAME to match other deployments ($nagios_context-$dashed_unitname)

Unmerged revisions

6. By JuanJo Ciarlante on 2013-09-30

[jjo,r=???] add nagios_context config, change NAGIOS_HOSTNAME to match other deployments ($nagios_context-$dashed_unitname)

5. By JuanJo Ciarlante on 2013-09-26

[jjo, r=mhall119] Add a basic api-website-relation-{joined,changed} hook, need as per provides (for reverseproxy-like FE services in-front) - requires setting {hostname,port} properly

4. By Michael Hall on 2013-09-23

Version bump to include new search functionality

3. By Michael Hall on 2013-09-20

Cleanup README

2. By Michael Hall on 2013-09-20

Fixes and changes

1. By Michael Hall on 2013-09-18

Initial Juju charm for Canonical IS deployments

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 2013-09-30 18:05:56 +0000
4@@ -0,0 +1,40 @@
5+Ubuntu API Website charm
6+========================
7+
8+* Deploys using postgresql and gunicorn
9+
10+Prerequisites
11+-------------
12+* Needs a reverse proxy server to point to gunicorn
13+* Needs an apache server to provide static files in response to /static/
14+
15+Setup charm config
16+------------------
17+* The default config is appropriate for production deployments.
18+
19+* To test the website running on it's own, you can generate a dev
20+* environment script using the command below:
21+cat > api-website.yaml <<EOF
22+api-website:
23+ instance_type: "dev"
24+ basedir: "api-website.local"
25+ url_root: "/"
26+ admin_node: True
27+ bzr_branch: "https://code.launchpad.net/+branch/ubuntu-api-website"
28+ bzr_revno: "last:1"
29+ debug_mode: True
30+ listen_port: 80
31+EOF
32+
33+Bootstrap and Deploy:
34+---------------------
35+export JUJU_REPOSITORY=${PWD}/api-website
36+juju bootstrap
37+juju deploy local:postgresql postgresql
38+juju deploy --config=api-website.yaml local:api-website api-website
39+juju deploy local:gunicorn gunicorn
40+
41+juju add-relation gunicorn api-website
42+juju add-relation postgresql:db api-website:db
43+
44+juju expose api-website
45
46=== renamed file 'README' => 'README.moved'
47=== added file 'config.yaml'
48--- config.yaml 1970-01-01 00:00:00 +0000
49+++ config.yaml 2013-09-30 18:05:56 +0000
50@@ -0,0 +1,108 @@
51+options:
52+ bzr_branch:
53+ type: string
54+ default: "https://code.launchpad.net/+branch/ubuntu-api-website"
55+ description: "API Website bzr source branch."
56+ bzr_revno:
57+ type: string
58+ default: "35"
59+ description: "API Website bzr revision."
60+ theme_branch:
61+ type: string
62+ default: "https://code.launchpad.net/+branch/ubuntu-community-webthemes/developer-django-theme/"
63+ description: "Ubuntu Devportal theme bzr source branch."
64+ theme_revno:
65+ type: string
66+ default: "54"
67+ description: "Ubuntu Devportal theme bzr revision."
68+ basedir:
69+ default: "ubuntu-api-website"
70+ type: string
71+ description: Base directory for code
72+ sitename:
73+ default: "developer.ubuntu.com"
74+ type: string
75+ description: Domain name site is accessed through
76+ url_root:
77+ default: "/"
78+ type: string
79+ description: URL path root, in case the site isn't on /
80+ debug_mode:
81+ default: False
82+ type: boolean
83+ description: Put Django into developer mode
84+ admin_node:
85+ default: False
86+ type: boolean
87+ description: Is this the node that should update the database
88+ instance_type:
89+ default: "production"
90+ type: string
91+ description: Instance type
92+ region:
93+ default: "prodstack"
94+ type: string
95+ description: Region we're deploying to
96+ user_code_runner:
97+ default: "apiwebsite"
98+ type: string
99+ description: The user that runs the code
100+ group_code_runner:
101+ default: "apiwebsite"
102+ type: string
103+ description: The group that runs the code
104+ user_code_owner:
105+ default: "webops_deploy"
106+ type: string
107+ description: The user that owns the code
108+ group_code_owner:
109+ default: "webops_deploy"
110+ type: string
111+ description: The group that owns the code
112+ listen_port:
113+ default: 8081
114+ type: int
115+ description: Port for the application to listen on
116+ wsgi_workers:
117+ type: int
118+ default: 2
119+ description: "The number of worker process for handling requests."
120+ wsgi_worker_class:
121+ type: string
122+ default: "gevent_wsgi"
123+ description: "Gunicorn workers type."
124+ wsgi_worker_connections:
125+ type: int
126+ default: 1000
127+ description: "The maximum number of simultaneous clients."
128+ wsgi_max_requests:
129+ type: int
130+ default: 0
131+ description: "The maximum number of requests a worker will process before restarting."
132+ wsgi_backlog:
133+ type: int
134+ default: 2048
135+ description: "The maximum number of pending connections."
136+ wsgi_timeout:
137+ type: int
138+ default: 30
139+ description: ""
140+ wsgi_keep_alive:
141+ type: int
142+ default: 2
143+ description: ""
144+ nrpe_url_check_params:
145+ default: "-e ' 200 OK' -u / -s '<title>Ubuntu App Developer</title>'"
146+ type: string
147+ description: The parameters to use for the nrpe check of the gunicorn IP and port
148+ nagios_context:
149+ default: "juju"
150+ type: string
151+ description: |
152+ Used by the nrpe-external-master subordinate charm.
153+ A string that will be prepended to instance name to set the host name
154+ in nagios. So for instance the hostname would be something like:
155+ juju-ubuntu-api-website-machine-0
156+ If you're running multiple environments with the same services in them
157+ this allows you to differentiate between them.
158+
159
160=== added directory 'files'
161=== added directory 'hooks'
162=== added symlink 'hooks/api-website-relation-changed'
163=== target is u'api-website-relation-joined'
164=== added file 'hooks/api-website-relation-joined'
165--- hooks/api-website-relation-joined 1970-01-01 00:00:00 +0000
166+++ hooks/api-website-relation-joined 2013-09-30 18:05:56 +0000
167@@ -0,0 +1,9 @@
168+#!/bin/bash
169+set -x
170+. hooks/common.sh
171+RID=$(relation-ids reverseproxy)
172+if [[ -n ${RID} ]]; then
173+ OPTION="-r $RID"
174+fi
175+relation-set $OPTION port="${LISTEN_PORT?}"
176+relation-set $OPTION hostname="$(unit-get private-address)"
177
178=== added file 'hooks/common.sh'
179--- hooks/common.sh 1970-01-01 00:00:00 +0000
180+++ hooks/common.sh 2013-09-30 18:05:56 +0000
181@@ -0,0 +1,83 @@
182+#!/bin/bash
183+
184+# Common variables used in setting up the service
185+MODE=$(config-get mode)
186+BASEDIR=$(config-get basedir)
187+BZR_SOURCE_BRANCH=$(config-get bzr_branch)
188+BZR_SOURCE_REVNO=$(config-get bzr_revno)
189+BZR_THEME_BRANCH=$(config-get theme_branch)
190+BZR_THEME_REVNO=$(config-get theme_revno)
191+BASEDIR=$(config-get basedir)
192+SITENAME=$(config-get sitename)
193+URL_ROOT=$(config-get url_root)
194+INSTANCE_TYPE=$(config-get instance_type)
195+REGION=$(config-get region)
196+USER_CODE_OWNER=$(config-get user_code_owner)
197+GROUP_CODE_OWNER=$(config-get group_code_owner)
198+USER_CODE_RUNNER=$(config-get user_code_runner)
199+GROUP_CODE_RUNNER=$(config-get group_code_runner)
200+LISTEN_PORT=$(config-get listen_port)
201+DEBUG_MODE=$(config-get debug_mode)
202+ADMIN_NODE=$(config-get admin_node)
203+WSGI_WORKERS=$(config-get wsgi_workers)
204+WSGI_WORKER_CLASS=$(config-get wsgi_worker_class)
205+WSGI_WORKER_CONNECTIONS=$(config-get wsgi_worker_connections)
206+WSGI_MAX_REQUESTS=$(config-get wsgi_max_requests)
207+WSGI_BACKLOG=$(config-get wsgi_backlog)
208+WSGI_TIMEOUT=$(config-get wsgi_timeout)
209+WSGI_KEEP_ALIVE=$(config-get wsgi_keep_alive)
210+
211+DB_ROLE=$(config-get db_role)
212+NRPE_URL_CHECK_PARAMS=$(config-get nrpe_url_check_params)
213+
214+DEPLOY_ROOT=/srv/${BASEDIR}/${INSTANCE_TYPE}
215+LOG_DIR=/srv/${BASEDIR}/${INSTANCE_TYPE}-logs
216+CODE_LOCATION=${DEPLOY_ROOT}/ubuntu-api-website
217+DJANGO_PROJECT=${CODE_LOCATION}/developer_network
218+MANAGE_PY=${DJANGO_PROJECT}/manage.py
219+LOCAL_CONFIG_LOCATION=${CODE_LOCATION}/developer_network
220+
221+# And this is for generating the deploymgr script from a template
222+JUJU_CONFIGS=$(/bin/mktemp --suffix=.juju)
223+config-get --format=json -o $JUJU_CONFIGS
224+
225+function manage_db {
226+ juju-log "Syncing the database for ubuntu-api-website..."
227+ python ${MANAGE_PY} syncdb --noinput --settings=local_settings
228+ python ${MANAGE_PY} migrate --noinput --settings=local_settings
229+ if [[ ${DEBUG_MODE} == "True" ]]; then
230+ juju-log "Loading sample data..."
231+ python ${MANAGE_PY} loaddata ${CODE_LOCATION}/developer_network/common/fixtures/sample_data.json --settings=local_settings
232+ python ${MANAGE_PY} loaddata ${CODE_LOCATION}/developer_network/apidocs/fixtures/sample_data.json --settings=local_settings
233+ fi
234+}
235+
236+function update_local_settings {
237+ juju-log "Creating local settings in ${LOCAL_CONFIG_LOCATION}/local_settings.py"
238+ juju-log "Creating local settings with URL_ROOT=${URL_ROOT}"
239+ cat > ${LOCAL_CONFIG_LOCATION}/local_settings.py <<EOF
240+# Local instance overrides
241+
242+from settings import *
243+
244+DEBUG=${DEBUG_MODE}
245+
246+URL_ROOT = '${URL_ROOT}'
247+
248+try:
249+ from db_settings import *
250+except Exception:
251+ pass
252+EOF
253+}
254+
255+function ctrl_service {
256+ # Check if there is an upstart or sysvinit service defined and issue the
257+ # requested command if there is. This is used to control services in a
258+ # friendly way when errexit is on.
259+ service_name=$1
260+ service_cmd=$2
261+ ( service --status-all 2>1 | grep -w $service_name ) && service $service_name $service_cmd
262+ ( initctl list 2>1 | grep -w $service_name ) && service $service_name $service_cmd
263+ return 0
264+}
265
266=== added file 'hooks/config-changed'
267--- hooks/config-changed 1970-01-01 00:00:00 +0000
268+++ hooks/config-changed 2013-09-30 18:05:56 +0000
269@@ -0,0 +1,56 @@
270+#!/bin/bash
271+
272+set -e
273+set -u
274+
275+. hooks/common.sh
276+
277+mkdir -p /srv/${BASEDIR}/${INSTANCE_TYPE}/
278+
279+# Make sure the code runner group can see all the code but only the code owner can change it
280+chown -R ${USER_CODE_OWNER}:${GROUP_CODE_RUNNER} $CODE_LOCATION
281+chmod -R u+rwX,go+rX,go-w $CODE_LOCATION
282+
283+# Configure deploymgr script
284+mkdir -p /srv/deploymgr/
285+
286+RID=$(relation-ids wsgi-file)
287+[ -n "$RID" ] && hooks/wsgi-file-relation-changed $RID
288+
289+HAD_DB_SETTINGS="False"
290+if [[ -f ${LOCAL_CONFIG_LOCATION}/db_settings.py ]]; then
291+ HAD_DB_SETTINGS="True"
292+fi
293+
294+# If this is a new revision of ubuntu-api-website get the new code
295+if [ ! -d ${CODE_LOCATION}-${BZR_SOURCE_REVNO} ]; then
296+ juju-log "Branching from ${BZR_SOURCE_BRANCH}:${BZR_SOURCE_REVNO} to ${CODE_LOCATION}-${BZR_SOURCE_REVNO}"
297+ bzr branch -r ${BZR_SOURCE_REVNO} ${BZR_SOURCE_BRANCH} ${CODE_LOCATION}-${BZR_SOURCE_REVNO}
298+
299+ if [ -d ${CODE_LOCATION} ]; then
300+ rm -r ${CODE_LOCATION}
301+ fi
302+ juju-log "Creating symlink from ${CODE_LOCATION}-${BZR_SOURCE_REVNO} to ${CODE_LOCATION}"
303+ ln -s ${CODE_LOCATION}-${BZR_SOURCE_REVNO} ${CODE_LOCATION}
304+
305+fi
306+
307+# If there is no theme checkout in the ubuntu-api-website branch get it now
308+if [ ! -d ${CODE_LOCATION}-${BZR_SOURCE_REVNO}/developer_network/ubuntu_website ]; then
309+ juju-log "Branching Theme from ${BZR_THEME_BRANCH}:${BZR_THEME_REVNO} to ${CODE_LOCATION}-${BZR_SOURCE_REVNO}/developer_network/ubuntu_website"
310+ bzr branch -r ${BZR_THEME_REVNO} ${BZR_THEME_BRANCH} ${CODE_LOCATION}-${BZR_SOURCE_REVNO}/developer_network/ubuntu_website
311+fi
312+
313+# Update local_settings.py
314+update_local_settings
315+
316+if [[ ${HAD_DB_SETTINGS} == "True" ]]; then
317+ DID=$(relation-ids db)
318+ [ -n "$DID" ] && hooks/db-relation-changed $DID
319+fi
320+
321+ctrl_service gunicorn restart
322+if [[ ${ADMIN_NODE} == "True" ]] && [[ -f ${LOCAL_CONFIG_LOCATION}/db_settings.py ]]; then
323+ manage_db
324+fi
325+
326
327=== added file 'hooks/db-relation-changed'
328--- hooks/db-relation-changed 1970-01-01 00:00:00 +0000
329+++ hooks/db-relation-changed 2013-09-30 18:05:56 +0000
330@@ -0,0 +1,45 @@
331+#!/bin/bash
332+
333+# Copyright 2012 Canonical Ltd. All rights reserved.
334+. hooks/common.sh
335+juju-log "Adding settings for the database service..."
336+
337+DB_NAME="api_website"
338+relation-set database=$DB_NAME
339+relation-set roles=$DB_ROLE
340+
341+
342+DB_USER=$(relation-get user)
343+DB_PASSWORD=$(relation-get password)
344+DB_HOST=$(relation-get private-address)
345+DB_PORT=$(relation-get port)
346+if [ -z "$DB_USER" ] ; then
347+ juju-log "Exiting, DB_USER not set ($DB_USER)"
348+ exit 0 # wait for future handshake from database service unit
349+fi
350+
351+if [[ ${DB_NAME} != $(relation-get database) ]]; then
352+ echo "Requested db not created yet"
353+ exit 0
354+fi
355+
356+cat > ${LOCAL_CONFIG_LOCATION}/db_settings.py <<EOF
357+DATABASES = {
358+ "default": {
359+ "ENGINE": "django.db.backends.postgresql_psycopg2",
360+ "NAME": "$DB_NAME",
361+ "USER": "$DB_USER",
362+ "PASSWORD": "$DB_PASSWORD",
363+ "HOST": "$DB_HOST",
364+ "PORT": "$DB_PORT",
365+ },
366+}
367+EOF
368+
369+chown ${USER_CODE_OWNER}:${GROUP_CODE_RUNNER} ${LOCAL_CONFIG_LOCATION}/db_settings.py
370+
371+if [[ ${ADMIN_NODE} == "True" ]]; then
372+ manage_db
373+fi
374+
375+ctrl_service gunicorn restart
376
377=== added symlink 'hooks/db-relation-joined'
378=== target is u'db-relation-changed'
379=== added file 'hooks/install'
380--- hooks/install 1970-01-01 00:00:00 +0000
381+++ hooks/install 2013-09-30 18:05:56 +0000
382@@ -0,0 +1,76 @@
383+#!/bin/bash
384+set -x
385+# Here do anything needed to install the service
386+# i.e. apt-get install -y foo or bzr branch http://myserver/mycode /srv/webroot
387+
388+juju-log "Beginning ubuntu-api-website install..."
389+# Pre-exec
390+if [[ -d exec.d ]]; then
391+ shopt -s nullglob
392+ for f in exec.d/*/charm-pre-install; do
393+ [[ -x "$f" ]] || continue
394+ ${SHELL} -c "$f"|| {
395+ ## bail out if anyone fails
396+ juju-log -l ERROR "$f: returned exit_status=$? "
397+ exit 1
398+ }
399+ done
400+fi
401+
402+juju-log "Importing common variables..."
403+. hooks/common.sh
404+
405+charm_dir=$(pwd)
406+
407+# Check if the groups already exists and create a new group if it doesn't
408+juju-log "Checking or creating groups: ${GROUP_CODE_OWNER} and ${GROUP_CODE_RUNNER}"
409+for group in $GROUP_CODE_OWNER $GROUP_CODE_RUNNER; do
410+ res=$(getent group | grep -c "^${group}:")
411+ if [[ $res -eq 0 ]]; then
412+ addgroup --quiet ${group}
413+ fi
414+done
415+
416+# Check if the users already exists and create a new user if it doesn't
417+juju-log "Checking or creating users: ${USER_CODE_OWNER} and ${USER_CODE_RUNNER}"
418+set +e
419+id $USER_CODE_OWNER
420+ret=$?
421+set -e
422+if [[ $ret -ne 0 ]]; then
423+ adduser --quiet --system --disabled-password --ingroup $GROUP_CODE_OWNER $USER_CODE_OWNER
424+fi
425+set +e
426+id $USER_CODE_RUNNER
427+ret=$?
428+set -e
429+if [[ $ret -ne 0 ]]; then
430+ adduser --quiet --system --disabled-password --ingroup $GROUP_CODE_RUNNER $USER_CODE_RUNNER
431+fi
432+
433+juju-log "Installing django and south packages..."
434+apt-get install -y bzr python-django python-django-south python-psycopg2 python-jinja2 python-gevent
435+
436+juju-log "Creating deployment directories..."
437+mkdir -p ${DEPLOY_ROOT} ${DEPLOY_ROOT}/local_config ${DEPLOY_ROOT}/scripts ${DEPLOY_ROOT}-logs /srv/${BASEDIR}/var
438+
439+juju-log "Branching from ${BZR_SOURCE_BRANCH}:${BZR_SOURCE_REVNO} to ${CODE_LOCATION}-${BZR_SOURCE_REVNO}"
440+bzr branch -r ${BZR_SOURCE_REVNO} ${BZR_SOURCE_BRANCH} ${CODE_LOCATION}-${BZR_SOURCE_REVNO}
441+
442+juju-log "Creating symlink from ${CODE_LOCATION}-${BZR_SOURCE_REVNO} to ${CODE_LOCATION}"
443+ln -s ${CODE_LOCATION}-${BZR_SOURCE_REVNO} ${CODE_LOCATION}
444+
445+bzr branch -r ${BZR_THEME_REVNO} ${BZR_THEME_BRANCH} ${CODE_LOCATION}-${BZR_SOURCE_REVNO}/developer_network/ubuntu_website
446+
447+# Update local_settings.py
448+update_local_settings
449+
450+juju-log "Changing ownership of /srv/${BASEDIR}"
451+chown -R $USER_CODE_OWNER:$GROUP_CODE_RUNNER /srv/${BASEDIR}
452+chmod -R g+w /srv/${BASEDIR}/var ${DEPLOY_ROOT}-logs
453+
454+juju-log "Collecting static files..."
455+python ${MANAGE_PY} collectstatic --noinput --settings=local_settings
456+
457+juju-log "Install of ubuntu-api-website complete!"
458+exit 0
459
460=== added file 'hooks/nrpe-external-master-relation-changed'
461--- hooks/nrpe-external-master-relation-changed 1970-01-01 00:00:00 +0000
462+++ hooks/nrpe-external-master-relation-changed 2013-09-30 18:05:56 +0000
463@@ -0,0 +1,40 @@
464+#!/bin/bash
465+set -eux
466+. hooks/common.sh
467+install --owner=root --group=root --mode=0555 scripts/check_status_file.sh /usr/lib/nagios/plugins/check_status_file.sh
468+export NAGIOS_CONTEXT="$(config-get nagios_context)"
469+export NAGIOS_SERVICEGROUP="${NAGIOS_CONTEXT}"
470+export NAGIOS_HOSTNAME="${NAGIOS_CONTEXT}-${JUJU_UNIT_NAME//\//-}"
471+
472+export INSTANCE_TYPE
473+export PROJECT="API_WEBSITE"
474+
475+export SERVICE_DESCRIPTION="Developer Portal API Website"
476+export NRPE_CMD_NAME="check_api_website_${INSTANCE_TYPE}"
477+export NRPE_CMD="/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p ${LISTEN_PORT} ${NRPE_URL_CHECK_PARAMS}"
478+cat > /etc/nagios/nrpe.d/${NRPE_CMD_NAME}.cfg <<EOF
479+#---------------------------------------------------
480+# This file is Juju managed
481+#---------------------------------------------------
482+# ${PROJECT} ${INSTANCE_TYPE} ${SERVICE_DESCRIPTION}
483+command[${NRPE_CMD_NAME}]=${NRPE_CMD}
484+
485+EOF
486+
487+# Admin nodes don't serve content
488+if [[ ${ADMIN_NODE} == "False" ]]; then
489+ cat > /var/lib/nagios/export/service__${NAGIOS_HOSTNAME}_${NRPE_CMD_NAME}.cfg <<EOF
490+#---------------------------------------------------
491+# This file is Juju managed
492+#---------------------------------------------------
493+define service {
494+ use active-service
495+ host_name ${NAGIOS_HOSTNAME}
496+ service_description ${NAGIOS_HOSTNAME} ${PROJECT} ${INSTANCE_TYPE} ${SERVICE_DESCRIPTION}
497+ check_command check_nrpe!${NRPE_CMD_NAME}
498+ servicegroups ${NAGIOS_SERVICEGROUP},
499+}
500+EOF
501+fi
502+
503+/etc/init.d/nagios-nrpe-server reload
504
505=== added file 'hooks/start'
506--- hooks/start 1970-01-01 00:00:00 +0000
507+++ hooks/start 2013-09-30 18:05:56 +0000
508@@ -0,0 +1,5 @@
509+#!/bin/bash
510+# Here put anything that is needed to start the service.
511+# Note that currently this is run directly after install
512+# i.e. 'service apache2 start'
513+exit 0
514
515=== added file 'hooks/stop'
516--- hooks/stop 1970-01-01 00:00:00 +0000
517+++ hooks/stop 2013-09-30 18:05:56 +0000
518@@ -0,0 +1,8 @@
519+#!/bin/bash
520+# This will be run when the service is being torn down, allowing you to disable
521+# it in various ways..
522+# For example, if your web app uses a text file to signal to the load balancer
523+# that it is live... you could remove it and sleep for a bit to allow the load
524+# balancer to stop sending traffic.
525+# rm /srv/webroot/server-live.txt && sleep 30
526+exit 0
527
528=== added symlink 'hooks/upgrade-charm'
529=== target is u'config-changed'
530=== added symlink 'hooks/website-cache-relation-changed'
531=== target is u'website-cache-relation-joined'
532=== added file 'hooks/website-cache-relation-joined'
533--- hooks/website-cache-relation-joined 1970-01-01 00:00:00 +0000
534+++ hooks/website-cache-relation-joined 2013-09-30 18:05:56 +0000
535@@ -0,0 +1,7 @@
536+#!/bin/bash
537+set -x
538+. hooks/common.sh
539+RID=$(relation-ids wsgi-file)
540+if [[ -n ${RID} ]]; then
541+ hooks/wsgi-file-relation-changed ${RID}
542+fi
543
544=== added file 'hooks/wsgi-file-relation-changed'
545--- hooks/wsgi-file-relation-changed 1970-01-01 00:00:00 +0000
546+++ hooks/wsgi-file-relation-changed 2013-09-30 18:05:56 +0000
547@@ -0,0 +1,22 @@
548+#!/bin/bash
549+
550+. hooks/common.sh
551+RID=$1
552+if [[ -n $RID ]]; then
553+ OPTION="-r $RID"
554+fi
555+relation-set $OPTION working_dir=${CODE_LOCATION}
556+relation-set $OPTION wsgi_workers="${WSGI_WORKERS}"
557+relation-set $OPTION wsgi_worker_class="${WSGI_WORKER_CLASS}"
558+relation-set $OPTION wsgi_worker_connections="${WSGI_WORKER_CONNECTIONS}"
559+relation-set $OPTION wsgi_max_requests="${WSGI_MAX_REQUESTS}"
560+relation-set $OPTION wsgi_backlog="${WSGI_BACKLOG}"
561+relation-set $OPTION wsgi_timeout="${WSGI_TIMEOUT}"
562+relation-set $OPTION wsgi_keep_alive="${WSGI_KEEP_ALIVE}"
563+relation-set $OPTION wsgi_user="${USER_CODE_RUNNER}"
564+relation-set $OPTION wsgi_group="${GROUP_CODE_RUNNER}"
565+relation-set $OPTION port="${LISTEN_PORT}"
566+relation-set $OPTION wsgi_access_logfile="${LOG_DIR}/access.log"
567+relation-set $OPTION wsgi_extra="'--error-logfile=${LOG_DIR}/error.log',"
568+relation-set $OPTION django_settings="local_settings"
569+relation-set $OPTION wsgi_wsgi_file="wsgi:application"
570
571=== added symlink 'hooks/wsgi-file-relation-joined'
572=== target is u'wsgi-file-relation-changed'
573=== added file 'metadata.yaml'
574--- metadata.yaml 1970-01-01 00:00:00 +0000
575+++ metadata.yaml 2013-09-30 18:05:56 +0000
576@@ -0,0 +1,19 @@
577+name: api-website
578+summary: Ubuntu API Website
579+description: |
580+ Deploy Devportal API Website
581+provides:
582+ wsgi-file:
583+ interface: wsgi
584+ scope: container
585+ api-website:
586+ interface: http
587+ nrpe-external-master:
588+ interface: nrpe-external-master
589+ scope: container
590+requires:
591+ website-cache:
592+ interface: http
593+ db:
594+ interface: pgsql
595+
596
597=== added file 'revision'
598--- revision 1970-01-01 00:00:00 +0000
599+++ revision 2013-09-30 18:05:56 +0000
600@@ -0,0 +1,1 @@
601+20
602\ No newline at end of file
603
604=== added directory 'scripts'
605=== added file 'scripts/check_status_file.sh'
606--- scripts/check_status_file.sh 1970-01-01 00:00:00 +0000
607+++ scripts/check_status_file.sh 2013-09-30 18:05:56 +0000
608@@ -0,0 +1,21 @@
609+#!/bin/bash
610+#------------------------------------------------------------
611+# This file is managed by Juju. Do not make local changes.
612+#------------------------------------------------------------
613+# Query a status file for current state
614+set -u
615+. /usr/lib/nagios/plugins/utils.sh
616+
617+STATUS_FILE=$1
618+if [[ ! -f ${STATUS_FILE} ]]; then
619+ echo "CRITICAL: Failed to open status file (${STATUS_FILE})"
620+ exit ${STATE_CRITICAL}
621+fi
622+STATUS=$(cat ${STATUS_FILE})
623+if [[ ${STATUS} == "OK" ]]; then
624+ echo "OK"
625+ exit ${STATE_OK}
626+else
627+ echo "CRITICAL: Status is ${STATUS}"
628+ exit ${STATE_CRITICAL}
629+fi

Subscribers

People subscribed via source and target branches