I have Django and Celery set up. I am only using one node for the worker.
我准备了姜戈和芹菜。我只使用一个节点作为工作人员。
I want to use use it as an asynchronous queue and as a scheduler.
我想把它用作异步队列和调度器。
I can launch the task as follows, with the -B option and it will do both.
我可以使用-B选项启动任务,如下所示。
celery worker start 127.0.0.1 --app=myapp.tasks -B
However it is unclear how to do this on production when I want to daemonise the process. Do I need to set up both the init scripts?
然而,当我想要使这个过程失效时,还不清楚如何在生产中实现这一点。我需要同时设置init脚本吗?
I have tried adding the -B option to the init.d script, but it doesn't seem to have any effect. The documentation is not very clear.
我已经尝试向init添加-B选项。d脚本,但似乎没有任何效果。文档不是很清楚。
2 个解决方案
#1
1
Personally I use Supervisord, which has some nice options and configurability. There are example supervisord config files here
我个人使用管理器,它有一些不错的选项和可配置性。这里有一个监管配置文件示例
#2
0
A couple of ways to achieve this: http://celery.readthedocs.org/en/latest/tutorials/daemonizing.html 1. Celery distribution comes with a generic init scripts located in path-to-celery/celery-3.1.10/extra/generic-init.d/celeryd
this can be placed in /etc/init.d/celeryd-name
and configured using a configuration file also present in the distribution which would look like the following
实现这个目标的几种方法:http://celery.readthedocs.org/en/latest/tutorials/daemoniz.html 1。芹菜分发附带了一个通用的init脚本,这些脚本位于路径到芹菜/ Celery - 3.10 /extra/generic-init中。这可以放在/etc/ init中。d/celeryd-name并使用配置文件配置,也显示在分布中,如下所示。
# Names of nodes to start (space-separated)
#CELERYD_NODES="my_application-node_1"
# Where to chdir at start. This could be the root of a virtualenv.
#CELERYD_CHDIR="/path/to/my_application"
# How to call celeryd-multi
#CELERYD_MULTI="$CELERYD_CHDIR/bin/celeryd-multi
# Extra arguments
#CELERYD_OPTS="--app=my_application.path.to.worker --time-limit=300 --concurrency=8 --loglevel=DEBUG"
# Create log/pid dirs, if they don't already exist
#CELERY_CREATE_DIRS=1
# %n will be replaced with the nodename
#CELERYD_LOG_FILE="/path/to/my_application/log/%n.log"
#CELERYD_PID_FILE="/var/run/celery/%n.pid"
# Workers run as an unprivileged user
#CELERYD_USER=my_user
#CELERYD_GROUP=my_group
You can add the following celerybeat elements for celery beat configuration to the file
您可以向文件中添加以下用于芹菜拍配置的celerybeat元素
# Where to chdir at start.
CELERYBEAT_CHDIR="/opt/Myproject/"
# Extra arguments to celerybeat
CELERYBEAT_OPTS="--schedule=/var/run/celery/celerybeat-schedule"
This config should be then saved in (atleast for centos) /etc/default/celeryd-config-name
Look at the init file for the exact location. now you can run celery as a daemon by running commands /etc/init.d/celeryd star/restart/stop
这个配置应该被保存在(至少是centos) /etc/default/celeryd-config-name中,查看init文件的确切位置。现在,您可以通过运行命令/etc/ initemon来运行芹菜。d / celeryd星形启动/停止
- Using supervisord. As mentioned in the other answer. The superviosord configuration files are also in the distribution path-to-dist/celery-version/extra/supervisord Configure using the files and use superviosrctl to run the service as a daemon
- 使用supervisord。正如在另一个答案中提到的。monitor sord配置文件也位于分发路径到dist/celery版本/extra/ supervision sord中,使用这些文件进行配置,并使用monitosrctl作为守护进程运行服务
#1
1
Personally I use Supervisord, which has some nice options and configurability. There are example supervisord config files here
我个人使用管理器,它有一些不错的选项和可配置性。这里有一个监管配置文件示例
#2
0
A couple of ways to achieve this: http://celery.readthedocs.org/en/latest/tutorials/daemonizing.html 1. Celery distribution comes with a generic init scripts located in path-to-celery/celery-3.1.10/extra/generic-init.d/celeryd
this can be placed in /etc/init.d/celeryd-name
and configured using a configuration file also present in the distribution which would look like the following
实现这个目标的几种方法:http://celery.readthedocs.org/en/latest/tutorials/daemoniz.html 1。芹菜分发附带了一个通用的init脚本,这些脚本位于路径到芹菜/ Celery - 3.10 /extra/generic-init中。这可以放在/etc/ init中。d/celeryd-name并使用配置文件配置,也显示在分布中,如下所示。
# Names of nodes to start (space-separated)
#CELERYD_NODES="my_application-node_1"
# Where to chdir at start. This could be the root of a virtualenv.
#CELERYD_CHDIR="/path/to/my_application"
# How to call celeryd-multi
#CELERYD_MULTI="$CELERYD_CHDIR/bin/celeryd-multi
# Extra arguments
#CELERYD_OPTS="--app=my_application.path.to.worker --time-limit=300 --concurrency=8 --loglevel=DEBUG"
# Create log/pid dirs, if they don't already exist
#CELERY_CREATE_DIRS=1
# %n will be replaced with the nodename
#CELERYD_LOG_FILE="/path/to/my_application/log/%n.log"
#CELERYD_PID_FILE="/var/run/celery/%n.pid"
# Workers run as an unprivileged user
#CELERYD_USER=my_user
#CELERYD_GROUP=my_group
You can add the following celerybeat elements for celery beat configuration to the file
您可以向文件中添加以下用于芹菜拍配置的celerybeat元素
# Where to chdir at start.
CELERYBEAT_CHDIR="/opt/Myproject/"
# Extra arguments to celerybeat
CELERYBEAT_OPTS="--schedule=/var/run/celery/celerybeat-schedule"
This config should be then saved in (atleast for centos) /etc/default/celeryd-config-name
Look at the init file for the exact location. now you can run celery as a daemon by running commands /etc/init.d/celeryd star/restart/stop
这个配置应该被保存在(至少是centos) /etc/default/celeryd-config-name中,查看init文件的确切位置。现在,您可以通过运行命令/etc/ initemon来运行芹菜。d / celeryd星形启动/停止
- Using supervisord. As mentioned in the other answer. The superviosord configuration files are also in the distribution path-to-dist/celery-version/extra/supervisord Configure using the files and use superviosrctl to run the service as a daemon
- 使用supervisord。正如在另一个答案中提到的。monitor sord配置文件也位于分发路径到dist/celery版本/extra/ supervision sord中,使用这些文件进行配置,并使用monitosrctl作为守护进程运行服务