Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Systemd for Django-q daemon

Tags:

python

django

I use Django-Q for task queue and scheduler. I need to keep running the command: python manage.py qcluster. How can I do it with Systemd?

I've found this code for .service file but I don't know how to use my Virtualenv for python path:

[Unit]
Description=Async tasks runner
After=network.target remote-fs.target

[Service]
ExecStart=/usr/bin/django-admin qcluster --pythonpath /path/to/project --settings settings
User=apache
Restart=always

[Install]
WantedBy=multi-user.target
like image 720
Amin.B Avatar asked Oct 16 '25 15:10

Amin.B


1 Answers

Use the django-admin binary installed in your virtualenv's bin directory, or the python binary there to run manage.py within your project's working directory:

ExecStart=/path/to/my-venv/bin/django-admin qcluster --pythonpath /path/to/project --settings settings

or

ExecStart=/path/to/my-venv/bin/python manage.py qcluster --pythonpath /path/to/project --settings settings
RootDirectory=/path/to/project
like image 115
AKX Avatar answered Oct 18 '25 06:10

AKX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!