Skip to content

Commit

Permalink
Restart Gunicorn, fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperna84 committed Feb 16, 2020
1 parent 21170f8 commit 4886e72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version 0.0.2 (2020-)
- Use proper logging
- Reject requests where supplied hostname does not match ORIGIN
- Add progressive web app functionality
- Send HUP to Gunicorn master process on saving settings (if Gunicorn is detected) (Issue #19)

Version 0.0.1 (2020-02-08)
- Initial release
5 changes: 5 additions & 0 deletions hass_wh_triggers/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import random
import base64
import signal
import datetime
import urllib.request

Expand Down Expand Up @@ -95,6 +96,7 @@
IGNORE_SSL = False
SSL_DEFAULT = ssl._create_default_https_context
SSL_UNVERIFIED = ssl._create_unverified_context
IS_GUNICORN = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "")

class ReverseProxied(object):
def __init__(self, app, script_name=None, scheme=None, server=None):
Expand Down Expand Up @@ -253,6 +255,9 @@ def settings():
ignore_ssl.value = '1' if request.values.get('ignore_ssl') else '0'
db.session.add(ignore_ssl)
db.session.commit()
if IS_GUNICORN:
app.logger.warning("Sending HUP to %i", os.getppid())
os.kill(os.getppid(), signal.SIGHUP)
load_settings()
return render_template('settings.html', title=TITLE,
session_timeout=SESSION_TIMEOUT,
Expand Down

0 comments on commit 4886e72

Please sign in to comment.