From 83f3488cf977ba6558dc8fc83b2e631c7dbc5dad Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Sun, 4 Mar 2018 11:19:23 +0100 Subject: [PATCH] #53 Provide server name for http proxy config --- README.md | 3 ++- bin/prom2teams | 5 +++-- bin/wsgi.py | 4 +++- prom2teams/app/configuration.py | 8 ++++---- prom2teams/config/settings.py | 4 +++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2b9ad44..1d44825 100644 --- a/README.md +++ b/README.md @@ -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 @@ -109,6 +109,7 @@ AnotherConnector: [HTTP Server] Host: # default: localhost Port: # default: 8089 +Name: # default: prom2teams [Log] Level: # default: DEBUG diff --git a/bin/prom2teams b/bin/prom2teams index 1bb8c17..ecb628a 100755 --- a/bin/prom2teams +++ b/bin/prom2teams @@ -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) diff --git a/bin/wsgi.py b/bin/wsgi.py index d6a5001..cdc0f22 100644 --- a/bin/wsgi.py +++ b/bin/wsgi.py @@ -10,4 +10,6 @@ if __name__ == "__main__": - application.run() + host = application.config['HOST'] + port = application.config['PORT'] + application.run(host=host, port=port) diff --git a/prom2teams/app/configuration.py b/prom2teams/app/configuration.py index a6dd13e..89c243f 100644 --- a/prom2teams/app/configuration.py +++ b/prom2teams/app/configuration.py @@ -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): diff --git a/prom2teams/config/settings.py b/prom2teams/config/settings.py index ffcd41c..79e61f6 100644 --- a/prom2teams/config/settings.py +++ b/prom2teams/config/settings.py @@ -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'