How to stop celery worker in my project?

Hello. I hope you're doing well. I have a django project running along with a celery worker for executing bg tasks. The code for starting the worker is in my profile like so: Web: celery -A config worker --loglevel=info --concurrency=4 & python manage.py migrate && gunicorn config.wsgi --bind 0.0.0.0:$PORT Now how do I remove all running tasks and restart the worker afresh?
6 Replies
Percy
Percy4mo ago
Project ID: 98888b3e-8302-4a34-a31a-6ba9963dccee
CodeLover
CodeLover4mo ago
Project id is : 98888b3e-8302-4a34-a31a-6ba9963dccee
Brody
Brody4mo ago
you are running two apps in one service, unless this is strictly needed, it is not best practice. you would want two services, one that runs celery and the other that runs gunicorn. these two services would deploy from the same repo and branch, have most of all the same service variables, but their start commands would be set to have one service run only celery and the other only run gunicorn, with this configuration you would not need a Procfile and would be free to stop celery without taking down the django site since now they are essentially separate
CodeLover
CodeLover4mo ago
Alright, I get your point. I already have a redis service in my project. Now practically speaking, can I start the celery server from the redis service (start command for example) instead of starting celery from my Procfile along with gunicorn?
Brody
Brody4mo ago
no, you need a new service please see my above message for the explanation
CodeLover
CodeLover4mo ago
Alright, I'll give it a try and get back to you in case I need further help