We set up an asynchronous task using Django, celery and rabbitMQ. Here our goal is to perform tasks like video transcoding, Thumbnail generation, Image compression and Image scaling altogether
We followed the below tutorial to implement it and the asynchronous task is working properly in Localhost. For the production compatibility, we used supervisord to start celery workers and to restart in case of system reboot or crash.
When we tried to implement same in AWS EC2, we are unable to install and configure Supervisord in AWS EC2.so we have to start celery manually every time. Can anyone please help us how to install and how to handle this procedure on AWS EC2
The code we are using
task.py
from __future__ import absolute_import
from test_celery.celery import app
import time
@app.task
def longtime_add(x, y):
print 'long time task begins'
# sleep 5 seconds
time.sleep(5)
print 'long time task finished'
return x + y
celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
import afnity.settings as settings
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
app = Celery('taskapp')
app.config_from_object('django.conf:settings')
if __name__ == '__main__':
app.start()
settings.py
BROKER_URL = 'amqp://guest:guest@localhost//'
CELERY_RESULT_BACKEND = 'redis://%s:%d/%d' % ('localhost', 6379, 0)