Hi,
I am new to celery and want to add a periodic task. I have tried everything but still not able to run the task in anyway. I am using edx fullstack and following are the steps I have followed.
1- In /edx/app/edxapp/edx-platform/lms/envs/aws.py, I have added:
CELERYBEAT_SCHEDULE['every-30s']={
'task': 'slam.tasks.test_4_celery',
'schedule': timedelta(seconds=30),
}
CELERY_TIMEZONE = TIMEZONE
2- In my django application, my tasks.py looks like:
@task()
def test_4_celery():
add FOO to mysql
3- Add a couple of users:
sudo rabbitmqctl add_user celery celery
sudo rabbitmqctl add_user edx edx
4- Add the host
sudo rabbitmqctl add_vhost edx_host
5- Allow users to access the host
sudo -p rabbitmqctl set_permissions edx_host celery ". *". "*" ". *"
sudo -p rabbitmqctl set_permissions edx_host edx ". *". "*" ". *"
6- Set users tag
sudo administrator rabbitmqctl celery set_user_tags
sudo administrator edx rabbitmqctl set_user_tags
7- In /edx/app/edxapp/edx-platform/lms/envs/aws.py, I have hard-coded the following:
CELERY_BROKER_VHOST = "edx_host"
CELERY_BROKER_HOSTNAME = "localhost"
CELERY_BROKER_TRANSPORT = "amqp"
CELERY_BROKER_PASSWORD = "edx"
CELERY_BROKER_USER = "edx"
---OUTPUT---
I am getting no output nor any error.
1- In "lms_low_1_stdout.log", i do see my task listed like
[tasks]
....
....
....
. slam.tasks.test_4_celery
2- In "lms_default_1-stderr.log", i see the following,
INFO 19907 [celery.worker.consumer] consumer.py:479 - Connected to ampq://edx:**127.0.0.1:5672/edx_host
INFO 19907 [celery.worker.consumer] consumer.py:567 - mingle: searching for neighbors
INFO 19907 [celery.worker.consumer] consumer.py:585 - mingle: all alone
WARNING 19907 [celery.redirected] log.py:282 - celery@edx.lms.core.default.edx-cwc ready
3- In "notifier-celery-workers-stderr.log", I don't see any error or warning related to my task (i.e. slam.tasks.test_4_celery)
4- I have also tried to start celerybeat service by:
edxapp@edx-cwc:~$ python /edx/app/edxapp/edx-platform/manage.py lms celerybeat --broker=amqp://celery@localhost:5672/edx_host
and I get the following error:
Configuration ->
. broker -> amqp://celery:**@localhost:5672/edx_host
. loader -> celery.loaders.app.AppLoader
. scheduler -> celery.beat.PersistentScheduler
. db -> celerybeat-schedule
. logfile -> [stderr]@%INFO
. maxinterval -> now (0s)
INFO:celery.beat:beat: Starting...ERROR:celery.beat:beat: Connection error: [Errno 104] Connection reset by peer. Trying again in 2.0 seconds...
BONUS: I have also tried to run the task by firing http request and it does add FOO into mysql database table which means there is not problem in my task.
Am i missing something to add this periodic task???? Kindly help me to solve this issue.
I shall be really grateful for any kind of help.
BR
Moiz