Browse Source

Move gunicorn server config out of INI files

gunicorn 20.0.0 included a change so that it will no longer read server
configuration out of Paster files. Because of this, the settings for it
in development.ini and production.ini were no longer being used. This
resulted in the auto-reloading no longer working in dev, and the number
of workers being reduced back down to 1 in production. The socket/PID
may have been impacted as well.

This commit moves the configuration into command-line args used to
launch gunicorn, and uses a pillar variable to handle the args different
between dev and prod.
merge-requests/88/head
Deimos 4 years ago
parent
commit
a47517e2b8
  1. 1
      salt/pillar/dev.sls
  2. 1
      salt/pillar/prod.sls
  3. 2
      salt/salt/gunicorn/gunicorn.service.jinja2
  4. 7
      tildes/development.ini
  5. 6
      tildes/production.ini.example

1
salt/pillar/dev.sls

@ -1,3 +1,4 @@
gunicorn_args: --reload
ini_file: development.ini
ssl_cert_path: /etc/pki/tls/certs/localhost.crt
ssl_private_key_path: /etc/pki/tls/certs/localhost.key

1
salt/pillar/prod.sls

@ -1,3 +1,4 @@
gunicorn_args: --workers 8
ini_file: production.ini
ssl_cert_path: /etc/letsencrypt/live/tildes.net/fullchain.pem
ssl_private_key_path: /etc/letsencrypt/live/tildes.net/privkey.pem

2
salt/salt/gunicorn/gunicorn.service.jinja2

@ -10,7 +10,7 @@ User={{ app_username }}
Group={{ app_username }}
RuntimeDirectory=gunicorn
WorkingDirectory={{ app_dir }}
ExecStart={{ bin_dir }}/gunicorn --paste {{ pillar['ini_file'] }} --config {{ app_dir }}/gunicorn_config.py
ExecStart={{ bin_dir }}/gunicorn --paste {{ pillar['ini_file'] }} --config {{ app_dir }}/gunicorn_config.py --bind unix:/run/gunicorn/socket --pid /run/gunicorn/pid {{ pillar['gunicorn_args'] }}
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true

7
tildes/development.ini

@ -43,10 +43,3 @@ webassets.base_dir = %(here)s/static
webassets.base_url = /
webassets.cache = false
webassets.manifest = json
[server:main]
use = egg:gunicorn#main
bind = unix:/run/gunicorn/socket
workers = 1
pidfile = /run/gunicorn/pid
reload = true

6
tildes/production.ini.example

@ -39,9 +39,3 @@ api_keys.embedly = embedlykeygoeshere
api_keys.stripe.publishable = pk_live_ActualKeyShouldGoHere
api_keys.stripe.secret = sk_live_ActualKeyShouldGoHere
api_keys.youtube = youtubekeygoeshere
[server:main]
use = egg:gunicorn#main
bind = unix:/run/gunicorn/socket
workers = 8
pidfile = /run/gunicorn/pid
Loading…
Cancel
Save