Merge lp:~gnuoy/charms/precise/gunicorn/fixed-bug-in-gunicorn-wsgi-mode into lp:~charmers/charms/precise/gunicorn/trunk

Proposed by Liam Young
Status: Merged
Merged at revision: 24
Proposed branch: lp:~gnuoy/charms/precise/gunicorn/fixed-bug-in-gunicorn-wsgi-mode
Merge into: lp:~charmers/charms/precise/gunicorn/trunk
Diff against target: 63 lines (+9/-17)
2 files modified
config.yaml (+4/-0)
hooks/wsgi-file-relation-joined (+5/-17)
To merge this branch: bzr merge lp:~gnuoy/charms/precise/gunicorn/fixed-bug-in-gunicorn-wsgi-mode
Reviewer Review Type Date Requested Status
Robert Ayres (community) Approve
Review via email: mp+127954@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Ayres (robert-ayres) wrote :

It seems if you change ports, nothing calls close-port to close the previously exposed port.

Also, the README requires updating to reflect the new change.

I'll modify the proposed merge.

Revision history for this message
Robert Ayres (robert-ayres) wrote :

Ignore the comment about closing port. There is no '*-broken' relation here anyway.

Updated README and merged.

Revision history for this message
Robert Ayres (robert-ayres) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2012-09-10 05:28:47 +0000
3+++ config.yaml 2012-10-04 08:13:21 +0000
4@@ -74,3 +74,7 @@
5 type: string
6 default: ""
7 description: "Set PYTHONPATH environment variable"
8+ port:
9+ type: int
10+ default: 8080
11+ description: "Default listen port"
12
13=== modified file 'hooks/wsgi-file-relation-joined'
14--- hooks/wsgi-file-relation-joined 2012-10-01 14:21:03 +0000
15+++ hooks/wsgi-file-relation-joined 2012-10-04 08:13:21 +0000
16@@ -9,7 +9,7 @@
17 exit 0 # wait for future handshake
18 fi
19
20-variables="wsgi_wsgi_file wsgi_workers wsgi_worker_class wsgi_worker_connections wsgi_max_requests wsgi_timeout wsgi_backlog wsgi_keep_alive wsgi_extra wsgi_user wsgi_group wsgi_umask wsgi_log_file wsgi_log_level wsgi_access_logfile wsgi_access_logformat env_extra django_settings python_path"
21+variables="wsgi_wsgi_file wsgi_workers wsgi_worker_class wsgi_worker_connections wsgi_max_requests wsgi_timeout wsgi_backlog wsgi_keep_alive wsgi_extra wsgi_user wsgi_group wsgi_umask wsgi_log_file wsgi_log_level wsgi_access_logfile wsgi_access_logformat env_extra django_settings python_path port"
22
23 if [[ $JUJU_RELATION_ID =~ django.* ]]; then
24 mode=django
25@@ -57,18 +57,6 @@
26 python_path=${VAR[python_path]}
27 fi
28
29-PORT=8080
30-quit=0
31-
32-while [ "$quit" -ne 1 ]; do
33- if [[ true == $(netstat -natl | grep 'tcp' | grep 'LISTEN' | awk '{print $4}' | cut -d: -f2 | grep -q $PORT || echo "true") ]]
34- then
35- quit=1
36- else
37- PORT=`expr $PORT + 1`
38- fi
39-done
40-
41 juju-log "Writing config file: /etc/gunicorn.d/${unit_name}.conf"
42
43 cat > /etc/gunicorn.d/${unit_name}.conf <<EOF
44@@ -92,7 +80,7 @@
45 '--timeout=${VAR[wsgi_timeout]}',
46 '--keep-alive=${VAR[wsgi_keep_alive]}',
47 '--umask=${VAR[wsgi_umask]}',
48- '--bind=0.0.0.0:${PORT}',
49+ '--bind=0.0.0.0:${VAR[port]}',
50 '--log-file=${VAR[wsgi_log_file]}',
51 '--log-level=${VAR[wsgi_log_level]}',
52 '--access-logfile=${VAR[wsgi_access_logfile]}',
53@@ -108,7 +96,7 @@
54
55 # We need this because when the contained charm configuration or code changed
56 # Gunicorn needs to restart to run the new code.
57-service gunicorn start || service gunicorn restart
58+service gunicorn restart
59
60-juju-log "Opening port: $PORT"
61-open-port $PORT/tcp
62+juju-log "Opening port: ${VAR[port]}"
63+open-port ${VAR[port]}/tcp

Subscribers

People subscribed via source and target branches

to all changes: