Commit 65cd6668 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Shutdown on signals

parent da136c00
......@@ -36,7 +36,7 @@ class Beacon(object):
Warning - closes only stateful connections, it does nothing to stateless ones.
For the optional parameters, see
logger.debug(' Received SIGINT or SIGTERM signal, disconnecting stateful data sources')
logger.debug(' Received SIGINT or SIGTERM signal {signum}, disconnecting stateful data sources')
def handle_include_dataset_responses(self, response: List[dict], responses, flag: str):
......@@ -11,6 +11,7 @@ Initially based on (MIT licensed) Python Beacon Development Kit
import json
import logging
import os
import signal
from flask import Flask
......@@ -71,6 +72,8 @@ def create_app(path_to_config_file="",
Creates the Flask application based on config object (Flask)
passed as an argument
:param path_to_config_file: path to a JSON file used to configure Flask instance
:param path_to_beacon_settings: optional, path to yaml file with beacon settings
:param path_to_data_sources_settings: optional, path to yaml file with data sources
:return: Flask application object
......@@ -105,8 +108,12 @@ def create_app(path_to_config_file="",
logger.debug(' - Registering views...')
register_views(app, beacon)
app.beacon = beacon
logger.debug(' - Mounting graceful-exit signal handlers...')
signal.signal(signal.SIGINT, beacon.shutdown)
signal.signal(signal.SIGTERM, beacon.shutdown)
logger.debug(' - Flask application has been correctly loaded!')
app.beacon = beacon
return app
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment