Issue
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
Solution
For those who still have problem with this, Just follow these steps:
- create a service, example:
sudo nano /etc/systemd/system/qcluster.service
- Edit service as follows:
[Unit] Description=qcluster runner After=network.target [Service] User=user WorkingDirectory=/home/user/path_to_project ExecStart=/home/user/path_to_project_env/bin/python manage.py qcluster [Install] WantedBy=multi-user.target
- Enable the service:
sudo systemctl enable qcluster.service
- Start the service:
sudo systemctl start qcluster.service
Answered By - Amin.B
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.