~verterok/charms/xenial/gunicorn/set-env-systemd

« back to all changes in this revision

Viewing changes to hooks/wsgi-file-relation-joined

  • Committer: Robert Ayres
  • Date: 2012-10-04 12:14:32 UTC
  • mfrom: (22.1.3 gunicorn)
  • Revision ID: robert.ayres@canonical.com-20121004121432-14uai7ktybwy074o
Merged changes from gnuoy

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
    exit 0 # wait for future handshake
10
10
fi
11
11
 
12
 
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"
 
12
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"
13
13
 
14
14
if [[ $JUJU_RELATION_ID =~ django.* ]]; then
15
15
    mode=django
57
57
    python_path=${VAR[python_path]}
58
58
fi
59
59
 
60
 
PORT=8080
61
 
quit=0
62
 
 
63
 
while [ "$quit" -ne 1 ]; do
64
 
    if [[ true == $(netstat -natl | grep 'tcp' | grep 'LISTEN' | awk '{print $4}' | cut -d: -f2 | grep -q $PORT || echo "true") ]]
65
 
    then
66
 
        quit=1
67
 
    else
68
 
        PORT=`expr $PORT + 1`
69
 
    fi
70
 
done
71
 
 
72
60
juju-log "Writing config file: /etc/gunicorn.d/${unit_name}.conf"
73
61
 
74
62
cat > /etc/gunicorn.d/${unit_name}.conf <<EOF
92
80
        '--timeout=${VAR[wsgi_timeout]}',
93
81
        '--keep-alive=${VAR[wsgi_keep_alive]}',
94
82
        '--umask=${VAR[wsgi_umask]}',
95
 
        '--bind=0.0.0.0:${PORT}',
 
83
        '--bind=0.0.0.0:${VAR[port]}',
96
84
        '--log-file=${VAR[wsgi_log_file]}',
97
85
        '--log-level=${VAR[wsgi_log_level]}',
98
86
        '--access-logfile=${VAR[wsgi_access_logfile]}',
108
96
 
109
97
# We need this because when the contained charm configuration or code changed
110
98
# Gunicorn needs to restart to run the new code.
111
 
service gunicorn start || service gunicorn restart
 
99
service gunicorn restart
112
100
 
113
 
juju-log "Opening port: $PORT"
114
 
open-port $PORT/tcp
 
101
juju-log "Opening port: ${VAR[port]}"
 
102
open-port ${VAR[port]}/tcp