Can't enable huey service on deploy server

吃可爱长大的小学妹 提交于 2021-02-07 22:26:45

问题


I'm working in a Django project deployment. I have integrated huey to run asynchronous tasks. Locally all runs perfectly but now, at the deployment step, I'm getting troubles about huey service activation. I really can't find any information about that because I think that solution should be so simple, bat I really can't find it :(.

I'm using nginx and gunicorn services. App runs perfectly on deploy server but huey tasks are not running. I have created a huey.service file located in /etc/systemd/system/, with the following content:

[Unit]
Description=Huey Service
After=redis.service

[Service]
User=deploy
Group=www-data
WorkingDirectory=/home/deploy/projects/myproject/
ExecStart=/usr/bin/python3.6 manage.py run_huey
Restart=always

[Install]
WantedBy=multi-user.target

But I'm getting following bug:

Nov 26 21:22:15 ip-172-31-11-39 python3.6[22543]:   File "manage.py", line 17, 
in <module>
Nov 26 21:22:15 ip-172-31-11-39 python3.6[22543]:  "Couldn't import Django. 
Are you sure it's installe
Nov 26 21:22:15 ip-172-31-11-39 python3.6[22543]: ImportError: Couldn't import 
Django. Are you sure it's
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: huey.service: Main process exited, 
code=exited, stat
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: huey.service: Unit entered failed state.
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: huey.service: Failed with result 'exit-code'.
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: huey.service: Service hold-off time over, scheduling
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: Stopped Huey Service.
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: huey.service: Start request repeated too quickly.
Nov 26 21:22:15 ip-172-31-11-39 systemd[1]: Failed to start Huey Service.

I think that huey service is not detecting a running virtualenv, and for this reason can't find django (Because it is in a virtualenv) but I have configured previously a gunicorn service to activate it; then, I don't know how to say huey service that an active virtualenv is already running and locate it.

This is my gunicorn file config:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=deploy
Group=www-data
WorkingDirectory=/home/deploy/projects/myproject
ExecStart=/home/deploy/projects/my project/project_env/bin/gunicorn --
access-logfile - --workers 3 --bind 
unix:/home/deploy/projects/myproject/project.sock app.wsgi:application
[Install]
WantedBy=multi-user.target

How should I activate huey service on deploy server? Thank you so much.


回答1:


Try using ExecStart=/home/deploy/projects/my project/project_env/bin/python manage.py run_huey



来源:https://stackoverflow.com/questions/47501317/cant-enable-huey-service-on-deploy-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!