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:14:07 +01:00
parent a35c1accd6
commit f277cc7169

View File

@ -49,28 +49,17 @@ app.config['MQTT_USERNAME'] = MQTT_USERNAME
app.config['MQTT_PASSWORD'] = MQTT_PASSWORD
app.config['MQTT_REFRESH_TIME'] = 1.0 # refresh time in seconds
app.config['SQLALCHEMY_DATABASE_URI'] = \
f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}"
f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}?sslmode=require"
api = Api(app)
db.init_app(app)
ma.init_app(app)
mqtt.init_app(app)
health = HealthCheck(app, "/healthz")
health = HealthCheck()
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)
@mqtt.on_log()
def handle_logging(client, userdata, level, buf):
@ -102,11 +91,4 @@ api.add_resource(SensorOfflineResource, "/devices/{deviceid}/{sensorid}/offline"
api.add_resource(SensorOnlineResource, "/devices/{deviceid}/{sensorid}/online")
health.add_check(health_database_status)
if __name__ == "__main__":
app.run(
debug=bool(DEBUG),
host="0.0.0.0",
use_reloader=False,
port=int(PORT),
)
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())