From a47517e2b8a43f0a1b5d3637d2fdcc67e49a408b Mon Sep 17 00:00:00 2001 From: Deimos Date: Tue, 17 Dec 2019 15:46:45 -0700 Subject: [PATCH] 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. --- salt/pillar/dev.sls | 1 + salt/pillar/prod.sls | 1 + salt/salt/gunicorn/gunicorn.service.jinja2 | 2 +- tildes/development.ini | 7 ------- tildes/production.ini.example | 6 ------ 5 files changed, 3 insertions(+), 14 deletions(-) diff --git a/salt/pillar/dev.sls b/salt/pillar/dev.sls index d756afd..6447f76 100644 --- a/salt/pillar/dev.sls +++ b/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 diff --git a/salt/pillar/prod.sls b/salt/pillar/prod.sls index 3a3a417..76cd5e6 100644 --- a/salt/pillar/prod.sls +++ b/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 diff --git a/salt/salt/gunicorn/gunicorn.service.jinja2 b/salt/salt/gunicorn/gunicorn.service.jinja2 index b5ee0d6..3fd06f5 100644 --- a/salt/salt/gunicorn/gunicorn.service.jinja2 +++ b/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 diff --git a/tildes/development.ini b/tildes/development.ini index 03cae9b..bd98b21 100644 --- a/tildes/development.ini +++ b/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 diff --git a/tildes/production.ini.example b/tildes/production.ini.example index b4e5923..84b58b4 100644 --- a/tildes/production.ini.example +++ b/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