Skip to content

Commit

Permalink
#53 Provide server name for http proxy config
Browse files Browse the repository at this point in the history
  • Loading branch information
jmonterrubio committed Mar 4, 2018
1 parent bd308df commit 83f3488
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ processes = 5
#socket = 0.0.0.0:8001
#protocol = http
socket = /tmp/prom2teams.sock
chmod-socket = 660
chmod-socket = 777
vacuum = true
env = APP_ENVIRONMENT=pro
env = APP_CONFIG_FILE=/etc/default/prom2teams.ini
Expand Down Expand Up @@ -109,6 +109,7 @@ AnotherConnector: <webhook url>
[HTTP Server]
Host: <host ip> # default: localhost
Port: <host port> # default: 8089
Name: <host name> # default: prom2teams
[Log]
Level: <loglevel (DEBUG|INFO|WARNING|ERROR|CRITICAL)> # default: DEBUG
Expand Down
5 changes: 3 additions & 2 deletions bin/prom2teams
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ except ImportError:
from prom2teams.app.api import app as application

if __name__ == "__main__":
_host, _port = application.config['SERVER_NAME'].split(':', 1)
application.run(host=_host, port=int(_port))
host = application.config['HOST']
port = application.config['PORT']
application.run(host=host, port=port)
4 changes: 3 additions & 1 deletion bin/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@


if __name__ == "__main__":
application.run()
host = application.config['HOST']
port = application.config['PORT']
application.run(host=host, port=port)
8 changes: 4 additions & 4 deletions prom2teams/app/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def _update_application_configuration(application, configuration):
if 'Log' in configuration and 'Path' in configuration['Log']:
application.config['LOG_FILE_PATH'] = configuration['Log']['Path']
if 'HTTP Server' in configuration:
_host, _port = application.config['SERVER_NAME'].split(':', 1)
if 'Host' in configuration['HTTP Server']:
_host = configuration['HTTP Server']['Host']
application.config['HOST'] = configuration['HTTP Server']['Host']
if 'Port' in configuration['HTTP Server']:
_port = configuration['HTTP Server']['Port']
application.config['SERVER_NAME'] = _host + ':' + _port
application.config['PORT'] = configuration['HTTP Server']['Port']
if 'Name' in configuration['HTTP Server']:
application.config['SERVER_NAME'] = configuration['HTTP Server']['Name']


def _config_provided(filepath):
Expand Down
4 changes: 3 additions & 1 deletion prom2teams/config/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
APP_NAME = 'prom2teams'
HOST = 'localhost'
PORT = 8089
# Flask settings
DEBUG = False
SERVER_NAME = 'localhost:8089'
SERVER_NAME = 'prom2teams'

# Flask-Restplus settings
SWAGGER_UI_DOC_EXPANSION = 'list'
Expand Down

0 comments on commit 83f3488

Please sign in to comment.