我想知道在生产环境中使用Django Q (https://django-q.readthedocs.io/en/latest/)时是否需要做一些特殊的事情。
我有一个Q_Cluster设置,我可以运行mange.py qcluster来启动我所有的计划任务。我会在生产中做同样的事情吗?
发布于 2021-07-19 14:55:03
Systemd是管理它的一个很好的方法。您还可以将日志放在附加到站点的文件夹中。我把我所有的配置文件和django应用放在同一个文件夹里,这样我就可以把它们放在同一个版本控制下。在实践中,它看起来像这样:
/web/example/config/example-qcluster.service:
[Unit]
Description=example qcluster daemon
After=network.target
[Service]
User=<web user>
Group=www-data
RuntimeDirectory=example
RuntimeDirectoryMode=0755
PIDFile=/run/example/qcluster.pid
WorkingDirectory=/web/example
EnvironmentFile=/web/example/.env
ExecStart=/web/example/env/bin/python manage.py qcluster
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
StandardOutput=file:/web/example/logs/qcluster.std.log
StandardError=file:/web/example/logs/qcluster.err.log
[Install]
WantedBy=multi-user.target然后,当然链接,启用并启动它:
sudo ln -s /web/example/config/example-qcluster.service /etc/systemd/system/example-qcluster.service
sudo systemctl enable example-qcluster.service
sudo systemctl start example-qcluster.service然后,您可以通过拖尾日志来检查它是否正常工作:
tail -f /web/example/logs/qcluster.std.loghttps://stackoverflow.com/questions/65241859
复制相似问题