您可以使用 apt-get 安装主管,然后您可以将以下内容添加到名为 celeryd.conf 的文件(或您希望的任何名称)到 etc/supervisor/conf.d 文件夹(如果不存在则创建 conf.d 文件夹)
; ==================================
; celery worker supervisor example
; ==================================
[program:celery]
; Set full path to celery program if using virtualenv
command=/home/<path to env>/env/bin/celery -A <appname> worker -l info
;enter the directory in which you want to run the app
directory=/home/<path to the app>
user=nobody
numprocs=1
stdout_logfile=/home/<path to the log file>/worker.log
stderr_logfile=/home/<path to the log file>/worker.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 1000
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998
还将以下行添加到 etc/supervisor/supervisord.conf
[include]
files = /etc/supervisor/conf.d/*.conf
现在通过在终端中输入 supervisord 来启动主管,celery 将根据您上面所做的设置自动启动。