在作正式环境,这个是必须的。

于是找了两小时文档,

以下这个方法,相对来说好实现。

就是要注意supervisord.conf的目录存放位置。

放在DJANGO的PROJ目录下,是最佳位置。

https://thomassileo.name/blog/2012/08/20/how-to-keep-celery-running-with-supervisor/

如何你不幸的和我一样,无法PIP只能用setup.py的话,可能celery和supervisord都要用绝对目录

[program:celeryd]
command=/usr/local/python27/bin/celery worker --app=ism -c 4 -l info
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=600

  

~~~~~~~~~~~~~~~~

Supervisor is a Python program that allows you to control and keep running any unix processes. It can also restart crashed processes. I use it to make sure Celery workers are always running.

I'm using virtualenv, Celery 3.0.5, and supervisor 3.0. I'm assuming Celery is already installed and configured.

Installation

First, you need to install supervisor in your virtualenv and generate a configuration file.

I store a supervisord.conf config file at the root of each project, and also, be careful to use theabsolute path to the Python interpreter of the virtualenv.

$ pip install supervisor
$ cd /path/to/your/project
$ echo_supervisord_conf > supervisord.conf

Next, just add this section after the [supervisord] section:

[program:celeryd]
command=/home/thomas/virtualenvs/yourvenv/bin/celery worker --app=myapp -l info
stdout_logfile=/path/to/your/logs/celeryd.log
stderr_logfile=/path/to/your/logs/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=600

It's a simplified version of the Celery supervisor example configuration file, adapted to work with virtualenvs.

Usage

Just run supervisord in your project directory.

$ supervisord

Then, you can use the supervisorctl command to enter the interactive shell. Type help to get started. You can also execute supervisor command directly:

$ supervisorctl tail celeryd
$ supervisorctl restart celeryd

And you ?

If you have any tips or suggestions, don't hesitate !

~~~~~~~~~~~~~~~

如何将CELERY放到后台执行?的更多相关文章

  1. linux 如何让程序后台执行

    $ (./test.sh &)   $ setsid ./test.sh &   $ nohup ./test.sh &   具体的转自:http://digdeeply.or ...

  2. linux后台执行命令&

    当在前台运行某个作业时,终端被该作业占据:而在后台运行作业时,它不会占据终端.可以使用&命令把作业放到后台执行. 如:30 2 * * * /data/app/scripts/hotbacku ...

  3. linux 命令后台执行

    我想把updatedb命令(用于重新建立整盘索引的命令)放在后台运行.因为我不想眼睁睁的看着机器建立索引,我还想编会儿程序呢: # updatedb & [1] 23336 注释:在所要执行的 ...

  4. linux命令后台执行

    fg.bg.jobs.&.nohup.ctrl+z.ctrl+c 命令 一.& 加在一个命令的最后,可以把这个命令放到后台执行,如 watch -n 10 sh test.sh &am ...

  5. Linux-把任务放到后台

    公司用的服务器,只能ssh远程操作,每天都会自动退出账户,不知道怎么回事儿,很郁闷.所以每天早起重新登录后发现进程已经关闭了,因为你运行的任务是和terminal关联在一起的,terminal关闭后, ...

  6. falsk 使用celery后台执行任务

    # falsk 使用celery后台执行任务 1.基础环境搭建 doc:https://flask.palletsprojects.com/en/1.0.x/patterns/celery/ mkdi ...

  7. nohup程序后台执行

    Linux常用命令,用于不挂断的执行程序. nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令.该命令可以在你退出帐户/关闭终端之后继续运行相应 ...

  8. Linux后台执行的方法 - 关闭、退出不影响

    =============================================================================================nohup c ...

  9. linux后台执行命令:&和nohup

    当我们在终端或控制台工作时,可能不希望由于运行一个作业而占住了屏幕,因为可能还有更重要的事情要做,比如阅读电子邮件.对于密集访问磁盘的进程,我们更希望它能够在每天的非负荷高峰时间段运行(例如凌晨).为 ...

随机推荐

  1. SharePoint2013 SharePoint-Hosted 模式 分页方法

    /**分页js插件 var ListPager = new listPaging(); 先调用start方法加载上下文 然后调用dataLoad方法查询第一页数据 需要设置几个属性值 ListPage ...

  2. 【转】MyBatis学习总结(三)——优化MyBatis配置文件中的配置

    [转]MyBatis学习总结(三)——优化MyBatis配置文件中的配置 一.连接数据库的配置单独放在一个properties文件中 之前,我们是直接将数据库的连接配置信息写在了MyBatis的con ...

  3. MySQL与NoSQL——SQL与NoSQL的融合

    来源:http://www.cnblogs.com/sunli/archive/2011/05/11/mysql-nosql.html 写这一篇内容的原因是MySQL5.6.2突然推出了memcach ...

  4. ios 兼容IPV4和IPV6网络通信

    前言: 苹果官方出了新的规定,要求新上架的app都必须单独支持ipv6-only的网络. 准备工作: 搭建IPV6测试环境:http://blog.csdn.net/potato512/article ...

  5. 对于jfinal中java.lang.Long cannot be cast to java.lang.Integer的解决方法

    @Jfinal 老大提供的解决方法 当数据库字段为 int 型(有符号int型),但是如果在 sql 中使用了某些函数,jdbc 会自动转型为 long,例如:select sum(money) fr ...

  6. JS代码大全 (都是网上看到 自己整理的)

    事件源对象  event.srcElement.tagName  event.srcElement.type 捕获释放  event.srcElement.setCapture();   event. ...

  7. Java异常(1)

    一.要达到的效果 如果出现错误而是某些操作没有完成,程序应该: (1)返回到一种安全状态,并能够让用户执行一些其他的命令. (2)允许用户保存所有操作的结果,并以适当的方式终止程序.   异常处理的任 ...

  8. Xml通用操作类

    using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Xml ...

  9. mysql常见的hint(转载的)

    mysql常用的hint对于经常使用oracle的朋友可能知道,oracle的hint功能种类很多,对于优化sql语句提供了很多方法.同样,在mysql里,也有类似的hint功能.下面介绍一些常用的. ...

  10. Mysql表操作

    查看表结构: 可以使用describe或show create table语句查看表的结构: describe表名; Show create table 表名; 修改表名: Alter table 旧 ...