Move code from mqtt __init__.py into separate modules
parent
df874fee6c
commit
b83a6cf70e
|
@ -31,7 +31,7 @@ def setup_blueprints(app):
|
||||||
from .devices.blueprint import devices_bp
|
from .devices.blueprint import devices_bp
|
||||||
from .dashboards.blueprint import dashboard_bp
|
from .dashboards.blueprint import dashboard_bp
|
||||||
from .api import api_bp
|
from .api import api_bp
|
||||||
from .mqtt import mqtt_bp
|
from .mqtt.blueprint import mqtt_bp
|
||||||
|
|
||||||
app.register_blueprint(accounts_bp)
|
app.register_blueprint(accounts_bp)
|
||||||
app.register_blueprint(devices_bp)
|
app.register_blueprint(devices_bp)
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import atexit
|
|
||||||
from flask import Blueprint
|
|
||||||
from .mqtt_client import MqttClient
|
|
||||||
|
|
||||||
mqtt_bp = Blueprint('mqtt', __name__)
|
|
||||||
|
|
||||||
|
|
||||||
# Setup
|
|
||||||
@mqtt_bp.record
|
|
||||||
def __on_blueprint_setup(setup_state):
|
|
||||||
MqttClient.setup(setup_state.app)
|
|
||||||
|
|
||||||
|
|
||||||
# When app dies, stop mqtt connection
|
|
||||||
def on_stop():
|
|
||||||
MqttClient.tear_down()
|
|
||||||
|
|
||||||
|
|
||||||
atexit.register(on_stop)
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
import atexit
|
||||||
|
from flask import Blueprint
|
||||||
|
from .mqtt_client import MqttClient
|
||||||
|
|
||||||
|
mqtt_bp = Blueprint('mqtt', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
@mqtt_bp.record
|
||||||
|
def __on_blueprint_setup(setup_state):
|
||||||
|
MqttClient.setup(setup_state.app)
|
||||||
|
|
||||||
|
|
||||||
|
# When app dies, stop mqtt connection
|
||||||
|
def on_stop():
|
||||||
|
MqttClient.tear_down()
|
||||||
|
|
||||||
|
|
||||||
|
atexit.register(on_stop)
|
Loading…
Reference in New Issue