3

How to activate virtual environment in server startup? When server restart i need to activate celery and workers. I am using ubuntu instance. Is cron jobs can do it?

this is the code i am using for starting celery tasks. i am using djcelery and django rest framework.

    ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9
    ps auxww | grep celery | awk '{print $2}' | xargs kill -9
    ps auxww | grep celeryd | awk '{print $2}' | xargs kill -9
    pkill -f "celery worker"

    nohup python manage.py celeryd &
    nohup python manage.py celerybeat --verbosity=2 --loglevel=DEBUG &

When server restart, i need to activate virtual environment and run all this commands again. is there any way to do it automatically?

tins johny
  • 195
  • 1
  • 13
  • Welcome in. Have you made any attempt at this issue so far? Would you be able to [edit] in more detail into your question to clarify any specific problems you've run into? – gravity Feb 13 '19 at 15:20
  • @gravitymixes Hi. i updated the question. is there any way to achieve this? i am using ubuntu server. – tins johny Feb 13 '19 at 15:37
  • you can setup celery in ubuntu using [this](https://www.digitalocean.com/community/tutorials/how-to-use-celery-with-rabbitmq-to-queue-tasks-on-an-ubuntu-vps) doc – paras chauhan Feb 14 '19 at 07:55

0 Answers0