在后台运行芹菜工人 [英] Run a celery worker in the background

查看:113
本文介绍了在后台运行芹菜工人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行芹菜工作人员是这样的:

I am running a celery worker like this:

celery worker --app=portalmq --logfile=/tmp/portalmq.log --loglevel=INFO -E --pidfile=/tmp/portalmq.pid

现在我要运行该工作人员在后台。我已经试过几件事,包括:

Now I want to run this worker in the background. I have tried several things, including:

nohup celery worker --app=portalmq --logfile=/tmp/portal_mq.log --loglevel=INFO -E --pidfile=/tmp/portal_mq.pid >> /tmp/portal_mq.log 2>&1 </dev/null &

但它不工作。我检查了芹菜的文档,我发现这一点:

But it is not working. I have checked the celery documentation, and I found this:

  • Running the worker as a daemon
  • Running the celery worker server

特别此评论是相关的:

In production you will want to run the worker in the background as a daemon.
To do this you need to use the tools provided by your platform, or something
like supervisord (see Running the worker as a daemon for more information).

这是过多的开销只是在后台运行的进程。我需要在我的服务器上安装supervisord,并熟悉它。没有走的时刻。有没有在backrground运行芹菜工作人员的的简单的办法吗?

This is too much overhead just to run a process in the background. I would need to install supervisord in my servers, and get familiar with it. No go at the moment. Is there a simple way of running a celery worker in the backrground?

推荐答案

导师是非常简单的,需要还真有点工作得到它安装起来,同样适用于芹菜与监督相结合。

supervisor is really simple and requires really little work to get it setup up, same applies for to celery in combination with supervisor.

这不应该超过10分钟的设置它:)

It should not take more than 10 minutes to setup it up :)


  1. 安装与supervisord apt-get的

  1. install supervisord with apt-get

创建/etc/supervisor/conf.d/celery.conf配置文件

create /etc/supervisor/conf.d/celery.conf config file

在celery.conf文件粘贴somethis

paste somethis in the celery.conf file

[program:celery]
directory = /my_project/
command = /usr/bin/python manage.py celery worker


  • 加(如果需要)一些可选的和有用的东西(使用虚假
    值)

  • plus (if you need) some optional and useful stuff (with dummy values)

    user = celery_user
    group = celery_group
    stdout_logfile = /var/log/celeryd.log
    stderr_logfile = /var/log/celeryd.err
    autostart = true
    environment=PATH="/some/path/",FOO="bar"
    


  • 重启主管(或做supervisorctl重读; supervisorctl添加
    芹菜)

  • restart supervisor (or do supervisorctl reread; supervisorctl add celery)

    在你得到很好的CTL命令管理芹菜的过程:

    after that you get the nice ctl commands to manage the celery process:

    supervisorctl start/restart/stop celery
    
    supervisorctl tail [-f] celery [stderr]
    

    这篇关于在后台运行芹菜工人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆