如何将CELERY放到后台执行?
在作正式环境,这个是必须的。
于是找了两小时文档,
以下这个方法,相对来说好实现。
就是要注意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
~~~~~~~~~~~~~~~~
How to keep Celery running with supervisor
Mon 20 August 2012 by Thomas Sileo
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放到后台执行?的更多相关文章
- linux 如何让程序后台执行
$ (./test.sh &) $ setsid ./test.sh & $ nohup ./test.sh & 具体的转自:http://digdeeply.or ...
- linux后台执行命令&
当在前台运行某个作业时,终端被该作业占据:而在后台运行作业时,它不会占据终端.可以使用&命令把作业放到后台执行. 如:30 2 * * * /data/app/scripts/hotbacku ...
- linux 命令后台执行
我想把updatedb命令(用于重新建立整盘索引的命令)放在后台运行.因为我不想眼睁睁的看着机器建立索引,我还想编会儿程序呢: # updatedb & [1] 23336 注释:在所要执行的 ...
- linux命令后台执行
fg.bg.jobs.&.nohup.ctrl+z.ctrl+c 命令 一.& 加在一个命令的最后,可以把这个命令放到后台执行,如 watch -n 10 sh test.sh &am ...
- Linux-把任务放到后台
公司用的服务器,只能ssh远程操作,每天都会自动退出账户,不知道怎么回事儿,很郁闷.所以每天早起重新登录后发现进程已经关闭了,因为你运行的任务是和terminal关联在一起的,terminal关闭后, ...
- falsk 使用celery后台执行任务
# falsk 使用celery后台执行任务 1.基础环境搭建 doc:https://flask.palletsprojects.com/en/1.0.x/patterns/celery/ mkdi ...
- nohup程序后台执行
Linux常用命令,用于不挂断的执行程序. nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令.该命令可以在你退出帐户/关闭终端之后继续运行相应 ...
- Linux后台执行的方法 - 关闭、退出不影响
=============================================================================================nohup c ...
- linux后台执行命令:&和nohup
当我们在终端或控制台工作时,可能不希望由于运行一个作业而占住了屏幕,因为可能还有更重要的事情要做,比如阅读电子邮件.对于密集访问磁盘的进程,我们更希望它能够在每天的非负荷高峰时间段运行(例如凌晨).为 ...
随机推荐
- requirejs 定义模块中含有prototype
因为我对requirejs不熟悉,不清楚如何定义带有prototype的模块, 在看了:https://gist.github.com/jonnyreeves/2474026 的demo之后,就明白了 ...
- HW-找7(测试ok满分注意小于等于30000的条件)
输出7有关数字的个数,包括7的倍数,还有包含7的数字(如17,27,37...70,71,72,73...)的个数 知识点 循环 运行时间限制 0M 内存限制 0 输入 一个正整数N.(N不大于300 ...
- Mysql_存储功能
先上一段代码: -->DELIMETER; ----加上这一句:DELIMETER的作用是设定客户机的分隔符,表示用//包含的是一段程序,一起执行,而不是见到“:”就执行 结束的时候写上 ...
- Objective-C 【类对象及SEL存储方式】
------------------------------------------- 类的本质--类对象 一段代码: #import <Foundation/Foundation.h> ...
- jquery之each
$.each()与$(selector).each()不同, 后者专用于jquery对象的遍历, 前者可用于遍历任何的集合(无论是数组或对象),如果是数组,回调函数每次传入数组的索引和对应的值(值亦可 ...
- Android笔记之adb命令应用实例1(手机端与PC端socket通讯上)
Android端的代码: 布局文件:activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/ ...
- 三栏布局的n种实现
本文主要讨论左右边栏固定宽度,中间栏填满其余空间的布局.至于其他类型,基本上也就是半斤和八两.每一种布局都会有个Demo,个人依然认为文章里帖代码并没有Demo来的直接.所以正文负责解释,源码参见De ...
- Mysql的权限管理
权限管理 创建用户 语法: create user '用户名'[@'主机名'][identified by '密码']; 示例: 说明: 用户名必须使用引号 '主机名'可以是以 ...
- 阅读 Linux 内核源码
阅读Linux Kernel Source Code 假如你在Linux系统下面阅读Linux内核源代码,那么需要准备一些工具. ①Linux的内核源码 内核源码的下载地址:Index of /pub ...
- (CodeForces 558C) CodeForces 558C
题目链接:http://codeforces.com/problemset/problem/558/C 题意:给出n个数,让你通过下面两种操作,把它们转换为同一个数.求最少的操作数. 1.ai = a ...