commit
db2371dcde
1
.env
1
.env
|
@ -1,3 +1,4 @@
|
||||||
DATABASE_URL="postgresql://localhost"
|
DATABASE_URL="postgresql://localhost"
|
||||||
REDIS_URL=redis://localhost:6379
|
REDIS_URL=redis://localhost:6379
|
||||||
CELERY_TASK_SERIALIZER=json
|
CELERY_TASK_SERIALIZER=json
|
||||||
|
DEBUG=True
|
||||||
|
|
2
Procfile
2
Procfile
|
@ -1,3 +1,3 @@
|
||||||
release: ./release-tasks.sh
|
release: ./release-tasks.sh
|
||||||
web: gunicorn app.core:app -w 4 --preload
|
web: gunicorn app.core:app -w 4 --preload
|
||||||
worker: celery -A app.celery_builder.celery worker
|
worker: celery -A app.celery_builder.task_builder worker
|
||||||
|
|
|
@ -7,3 +7,4 @@ app.config.from_object('config')
|
||||||
app.config.from_pyfile('config.py', silent=True)
|
app.config.from_pyfile('config.py', silent=True)
|
||||||
app.config['MQTT_CLIENT_ID'] = 'final-iot-backend-server-worker'
|
app.config['MQTT_CLIENT_ID'] = 'final-iot-backend-server-worker'
|
||||||
task_builder = make_celery(app)
|
task_builder = make_celery(app)
|
||||||
|
task_builder.autodiscover_tasks(['app.devices'])
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import sys
|
import sys
|
||||||
from app.celery_builder import task_builder
|
from app.celery_builder import task_builder
|
||||||
from .blueprint import devices_bp
|
from flask import current_app as app
|
||||||
|
|
||||||
|
|
||||||
@task_builder.task()
|
@task_builder.task()
|
||||||
def send_config(device_id, config):
|
def send_config(device_id, config):
|
||||||
from flask_mqtt import Mqtt, MQTT_ERR_SUCCESS
|
from flask_mqtt import Mqtt, MQTT_ERR_SUCCESS
|
||||||
mqtt = Mqtt(devices_bp)
|
mqtt = Mqtt(app)
|
||||||
|
|
||||||
@mqtt.on_log()
|
@mqtt.on_log()
|
||||||
def handle_logging(client, userdata, level, buf):
|
def handle_logging(client, userdata, level, buf):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# App configuration
|
# App configuration
|
||||||
DEBUG = False
|
DEBUG = os.environ['DEBUG']
|
||||||
|
|
||||||
# Define the application directory
|
# Define the application directory
|
||||||
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
Loading…
Reference in New Issue