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?