update helathcheck
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-12-06 11:16:09 +01:00
parent 5d5bb9cd92
commit a1ee937f32

View File

@ -35,7 +35,7 @@ if SENTRY_DSN:
app = Flask(__name__)
app.config[
'SQLALCHEMY_DATABASE_URI'] = f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}"
'SQLALCHEMY_DATABASE_URI'] = f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}?sslmode=require"
app.config['EXCHANGE_NAME'] = RABBITMQ_EXCHANGE
app.config['FLASK_PIKA_PARAMS'] = {'host': RABBITMQ_HOST,
'username': RABBITMQ_USERNAME,
@ -43,32 +43,15 @@ app.config['FLASK_PIKA_PARAMS'] = {'host': RABBITMQ_HOST,
'port': 5672,
'virtual_host': '/'}
api = Api(app)
health = HealthCheck(app, "/healthz")
health = HealthCheck()
db.init_app(app)
ma.init_app(app)
with app.app_context():
db.create_all()
formatter = logging.Formatter(
fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s"
)
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
api.add_resource(SampleResource, "/sample")
api.add_resource(SampleParameterResource, '/sample/<tag>')
health.add_check(health_database_status)
if __name__ == "__main__":
app.run(
debug=bool(DEBUG),
host="0.0.0.0",
port=int(PORT),
)
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())