Fix celery task runner and task import

master
esensar 2018-10-08 21:08:50 +02:00
parent 78128d4282
commit 04f3cb3045
5 changed files with 6 additions and 4 deletions

1
.env
View File

@ -1,3 +1,4 @@
DATABASE_URL="postgresql://localhost"
REDIS_URL=redis://localhost:6379
CELERY_TASK_SERIALIZER=json
DEBUG=True

View File

@ -1,3 +1,3 @@
release: ./release-tasks.sh
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

View File

@ -7,3 +7,4 @@ app.config.from_object('config')
app.config.from_pyfile('config.py', silent=True)
app.config['MQTT_CLIENT_ID'] = 'final-iot-backend-server-worker'
task_builder = make_celery(app)
task_builder.autodiscover_tasks(['app.devices'])

View File

@ -1,12 +1,12 @@
import sys
from app.celery_builder import task_builder
from .blueprint import devices_bp
from flask import current_app as app
@task_builder.task()
def send_config(device_id, config):
from flask_mqtt import Mqtt, MQTT_ERR_SUCCESS
mqtt = Mqtt(devices_bp)
mqtt = Mqtt(app)
@mqtt.on_log()
def handle_logging(client, userdata, level, buf):

View File

@ -1,7 +1,7 @@
import os
# App configuration
DEBUG = False
DEBUG = os.environ['DEBUG']
# Define the application directory
BASE_DIR = os.path.abspath(os.path.dirname(__file__))