diff --git a/CHANGELOG.md b/CHANGELOG.md
index 94a83bc..1a0774b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).
## [Unreleased](https://github.com/idealista/prom2teams/tree/develop)
+## [2.0.1](https://github.com/idealista/prom2teams/tree/2.0.1)
+[Full Changelog](https://github.com/idealista/prom2teams/compare/2.0.0...2.0.1)
+### Fixed
+- *[#53](https://github.com/idealista/prom2teams/issues/53) Fix prom2teams uwsgi bin startup* @jmonterrubio
## [2.0.0](https://github.com/idealista/prom2teams/tree/2.0.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/1.3.0...2.0.0)
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 988102e..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM python:3.5-slim-jessie
-
-LABEL maintainer="labs@idealista.com"
-
-EXPOSE 8089
-
-RUN pip install prom2teams
-COPY config.ini /opt/prom2teams/config.ini
-
-ENTRYPOINT ["prom2teams", "--configpath", "/opt/prom2teams/config.ini"]
diff --git a/MANIFEST.in b/MANIFEST.in
index 034ff77..41a7dd2 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,6 @@
include README.md
include LICENSE
include requirements.txt
+include bin/wsgi.py
include */config/*
recursive-include */resources/ *
diff --git a/README.md b/README.md
index 9628d7a..33b8306 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
![Logo](https://raw.githubusercontent.com/idealista/prom2teams/master/logo.gif)
-[![Build Status](https://travis-ci.org/idealista/prom2teams.png)](https://travis-ci.org/idealista/prom2teams)
+[![Build Status](https://travis-ci.org/idealista/prom2teams.png)](https://travis-ci.org/idealista/prom2teams) [![Docker Automated build](https://img.shields.io/docker/automated/jrottenberg/ffmpeg.svg)](https://hub.docker.com/r/idealista/prom2teams/) [![Docker Build Status](https://img.shields.io/docker/build/jrottenberg/ffmpeg.svg)](https://hub.docker.com/r/idealista/prom2teams/)
# prom2teams
-
+
**prom2teams** is a Web server built with Python that receives alert notifications from a previously configured [Prometheus Alertmanager](https://github.com/prometheus/alertmanager) instance and forwards it to [Microsoft Teams](https://teams.microsoft.com/) using defined connectors.
@@ -59,7 +59,13 @@ export APP_CONFIG_FILE=
$ prom2teams
```
-For production environments you should prefer using a WSGI server. You can launch instead:
+### Production
+
+For production environments you should prefer using a WSGI server. [uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/)
+dependency is installed for an easy usage. Some considerations must be taken to use it:
+
+The binary `prom2teams_uwsgi` launches the app using the uwsgi server. Due to some incompatibilities with [wheel](https://github.com/pypa/wheel)
+you must install `prom2teams` using `sudo pip install --no-binary :all: prom2teams` (https://github.com/pypa/wheel/issues/92)
```bash
$ prom2teams_uwsgi
@@ -74,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
@@ -82,6 +88,10 @@ env = APP_CONFIG_FILE=/etc/default/prom2teams.ini
Consider not provide `chdir` property neither `module` property.
+Also you can set the `module` file, by doing a symbolic link: `sudo mkdir -p /usr/local/etc/prom2teams/ && sudo ln -sf /usr/local/lib/python3.5/dist-packages/usr/local/etc/prom2teams/wsgi.py /usr/local/etc/prom2teams/wsgi.py` (check your dist-packages folder)
+
+Another approach is to provide yourself the `module` file [module example](bin/wsgi.py) and the `bin` uwsgi call [uwsgi example](bin/prom2teams_uwsgi)
+
**Note:** default log level is DEBUG. Messages are redirected to stdout. To enable file log, set the env APP_ENVIRONMENT=(pro|pre)
@@ -92,13 +102,14 @@ The config file is an [INI file](https://docs.python.org/3/library/configparser.
```
[Microsoft Teams]
# At least one connector is required here
-Connector:
+Connector:
AnotherConnector:
...
[HTTP Server]
Host: # default: localhost
Port: # default: 8089
+Name: # default: localhost:8089
[Log]
Level: # default: DEBUG
@@ -134,11 +145,11 @@ Other optional fields are skipped and not included in the Teams message.
Accessing to `:` (e.g. `localhost:8001`) in a web browser shows the API v1 documentation.
-
+
Accessing to `:/v2` (e.g. `localhost:8001/v2`) in a web browser shows the API v2 documentation.
-
+
## Testing
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/prom2teams_uwsgi b/bin/prom2teams_uwsgi
index 6e0a9b9..9db9cb6 100755
--- a/bin/prom2teams_uwsgi
+++ b/bin/prom2teams_uwsgi
@@ -9,4 +9,4 @@ else
exit 1
fi
-uwsgi $config --chdir `dirname "$0"` --module wsgi
+uwsgi $config --chdir /usr/local/etc/prom2teams --module wsgi
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/dockerhub/Dockerfile b/dockerhub/Dockerfile
index 6fe7e27..19c0f0c 100644
--- a/dockerhub/Dockerfile
+++ b/dockerhub/Dockerfile
@@ -1,9 +1,10 @@
-FROM python:3.5-slim-jessie
+FROM python:3.6-slim-stretch
LABEL maintainer="labs@idealista.com"
EXPOSE 8089
+RUN apt-get update && apt-get install -y build-essential
RUN pip install prom2teams
COPY config.ini /opt/prom2teams/config.ini
COPY prom2teams_start.sh /opt/prom2teams/prom2teams_start.sh
diff --git a/prom2teams/app/configuration.py b/prom2teams/app/configuration.py
index a6dd13e..53f0eb9 100644
--- a/prom2teams/app/configuration.py
+++ b/prom2teams/app/configuration.py
@@ -37,9 +37,14 @@ def _update_application_configuration(application, configuration):
_host, _port = application.config['SERVER_NAME'].split(':', 1)
if 'Host' in configuration['HTTP Server']:
_host = configuration['HTTP Server']['Host']
+ application.config['HOST'] = _host
if 'Port' in configuration['HTTP Server']:
_port = configuration['HTTP Server']['Port']
- application.config['SERVER_NAME'] = _host + ':' + _port
+ application.config['PORT'] = _port
+ if 'Name' in configuration['HTTP Server']:
+ application.config['SERVER_NAME'] = configuration['HTTP Server']['Name']
+ else:
+ application.config['SERVER_NAME'] = _host + ':' + _port
def _config_provided(filepath):
diff --git a/prom2teams/config/settings.py b/prom2teams/config/settings.py
index ffcd41c..7230226 100644
--- a/prom2teams/config/settings.py
+++ b/prom2teams/config/settings.py
@@ -1,4 +1,6 @@
APP_NAME = 'prom2teams'
+HOST = 'localhost'
+PORT = 8089
# Flask settings
DEBUG = False
SERVER_NAME = 'localhost:8089'
diff --git a/setup.py b/setup.py
index c0c4172..9522053 100644
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@ def read_requirements_file():
setup(name='prom2teams',
- version='2.0.0',
+ version='2.0.1',
description='Project that redirects Prometheus Alert Manager '
'notifications to Microsoft Teams',
long_description=readme,
@@ -41,6 +41,9 @@ def read_requirements_file():
'': ['*.ini', '*.j2'],
},
include_package_data=True,
+ data_files=[
+ ('/usr/local/etc/prom2teams', ['bin/wsgi.py'])
+ ],
url='http://github.com/idealista/prom2teams',
author='Idealista, S.A.U',
author_email='labs@idealista.com',