gpt4 book ai didi

django - 无法在部署服务器上启用 huey 服务

转载 作者:行者123 更新时间:2023-12-01 13:27:57 24 4
gpt4 key购买 nike

我正在 Django 项目部署中工作。我已经集成了 huey 来运行异步任务。在本地一切运行完美,但现在,在部署步骤中,我遇到了有关 huey 服务激活的麻烦。我真的找不到任何相关信息,因为我认为解决方案应该如此简单,但我真的找不到它:(。

我正在使用 nginx 和 gunicorn 服务。应用程序在部署服务器上运行完美,但 huey 任务未运行。我在 /etc/systemd/system/ 中创建了一个 huey.service 文件,内容如下:

[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

但我遇到了以下错误:

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.

我认为 huey 服务没有检测到正在运行的 virtualenv,因此找不到 django(因为它在 virtualenv 中)但我之前配置了一个 gunicorn 服务来激活它;然后,我不知道如何说 huey service 一个事件的 virtualenv 已经在运行并找到它。

这是我的 gunicorn 文件配置:

[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

我应该如何在部署服务器上激活 huey 服务?非常感谢。

最佳答案

尝试使用 ExecStart=/home/deploy/projects/my project/project_env/bin/python manage.py run_huey

关于django - 无法在部署服务器上启用 huey 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47501317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com