-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
80 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[run] | ||
include= | ||
*project/* | ||
*pyms/* | ||
omit = | ||
venv/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
FROM python:3.6.4-alpine3.7 | ||
|
||
RUN apk add --update curl gcc g++ libffi-dev openssl-dev python3-dev \ | ||
RUN apk add --update curl gcc g++ git libffi-dev openssl-dev python3-dev \ | ||
&& rm -rf /var/cache/apk/* | ||
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h | ||
|
||
ENV PYTHONUNBUFFERED=1 ENVIRONMENT=pre APP_HOME=/microservice/ | ||
RUN mkdir $APP_HOME && adduser -S -D -H python | ||
|
||
RUN mkdir $APP_HOME | ||
RUN chown -R python $APP_HOME | ||
WORKDIR $APP_HOME | ||
ADD requirement*.txt $APP_HOME | ||
RUN pip install -r requirements-docker.txt | ||
ADD . $APP_HOME | ||
|
||
EXPOSE 5000 | ||
USER python | ||
|
||
CMD ["gunicorn", "--worker-class", "eventlet", "--workers", "8", "--log-level", "INFO", "--bind", "0.0.0.0:5000", "manage:app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
# encoding: utf-8 | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
from flask_sqlalchemy import SQLAlchemy | ||
|
||
db = SQLAlchemy() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# coding=utf-8 | ||
from __future__ import unicode_literals, print_function, absolute_import, division | ||
|
||
from flask import Blueprint | ||
|
||
healthcheck_blueprint = Blueprint('healthcheck', __name__, static_url_path='/static') | ||
|
||
from pyms.healthcheck import healthcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import opentracing | ||
import requests | ||
from flask_opentracing import FlaskTracer | ||
|
||
from pyms.healthcheck import healthcheck_blueprint | ||
|
||
|
||
@healthcheck_blueprint.route('/healthcheck', methods=['GET']) | ||
def healthcheck(tracer: FlaskTracer): | ||
span = tracer.get_span() | ||
headers = {} | ||
tracer._tracer.inject(span, opentracing.Format.HTTP_HEADERS, headers) | ||
result = requests.post(url="http://localhost:8081/oauth/login", data={ | ||
"username": "test", | ||
"password": "1234" | ||
}, headers=headers) | ||
return result.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# encoding: utf-8 | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
from flask_sqlalchemy import SQLAlchemy | ||
|
||
db = SQLAlchemy() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from flask_opentracing import FlaskTracer | ||
from injector import Module | ||
from jaeger_client import Config | ||
|
||
|
||
def init_jaeger_tracer(service_name='your-app-name'): | ||
"""This scaffold is configured whith `Jeager <https://github.com/jaegertracing/jaeger>`_ but you can use | ||
one of the `opentracing tracers <http://opentracing.io/documentation/pages/supported-tracers.html>`_ | ||
:param service_name: the name of your application to register in the tracer | ||
:return: opentracing.Tracer | ||
""" | ||
config = Config(config={ | ||
'sampler': {'type': 'const', 'param': 1}, 'logging': True, | ||
}, service_name=service_name) | ||
return config.initialize_tracer() | ||
|
||
|
||
class TracerModule(Module): | ||
def __init__(self, app): | ||
self.app = app | ||
|
||
def configure(self, binder): | ||
tracer = init_jaeger_tracer(self.app.config["APP_NAME"]) | ||
binder.bind(FlaskTracer, to=FlaskTracer(tracer, True, self.app)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
-e git+https://github.com/jaegertracing/jaeger-client-python.git#egg=jaeger_client | ||
flasgger==0.8.1 | ||
Flask==0.12.2 | ||
Flask-Injector==0.10.1 | ||
Flask-OpenTracing==0.1.8 | ||
Flask-Script==2.0.6 | ||
Flask-SQLAlchemy==2.3.2 | ||
Flask-Testing==0.7.1 | ||
SQLAlchemy==1.2.5 | ||
requests==2.18.4 | ||
jaeger-client==3.7.1 |