注意启停的先后顺序及判断即可。

这样,在更改task之后,要重启就方便很多啦。。

#!/bin/sh

supervisord_count=`ps -elf | grep celery | grep -v grep | wc -l`
 ]; then

fi

celery_count=`ps -elf | grep celery | grep -v grep | wc -l`
 ]; then

fi

/usr/bin/python /usr/local/python27/bin/supervisord -c /P/supervisord_prd.conf
sh /usr/local/nginx/sbin/uwsgi9090 reload
/usr/local/nginx/sbin/nginx -s reload

echo 'finished!'

另给一个最基本的supervisor的设置:

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".

[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=           ; (num of main logfile rotation backups;default )
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=                  ; (min. avail startup )
minprocs=                 ; (min. avail process descriptors;default )
;umask=                   ; (process )
;user=chrism                 ; (default is current user, required if root)
;identifier=supervisor       ; (supervisord identifier, default is 'supervisor')
;directory=/tmp              ; (default is not to cd during start)
;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;environment=KEY="value"     ; (key value pairs to add to environment)
;strip_ansi=false            ; (strip ansi escape codes in logs; def. false)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket

[program:celeryd]
command=/usr/local/python27/bin/celery worker -A XXXX -c    -l INFO -n celeryd@deploy
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=
stopwaitsecs=

;[program:celerybeat]
;command=/usr/local/python27/bin/celery worker -A XXXX -c    -B -n celerybeat@ping
;stdout_logfile=/var/log/celeryd.log
;stderr_logfile=/var/log/celeryd.log
;autostart=true
;autorestart=true
;startsecs=
;stopwaitsecs=

用supervisor控制celery时的脚本的更多相关文章

  1. 【原创】控制perl和python脚本执行过程中脚本文件是否关闭的方法

    引子 跟踪perl和python脚本对文件的访问,实际过程中,perl和python解析器在解析完脚本后,直接关闭了 脚本文件,在进程中查询不到是访问文件的脚本文件名称. shell.perl和pyt ...

  2. 使用 supervisor 管理 Celery 服务

    使用 supervisor 管理 Celery 服务 Celery 后台运行 如果我们想让celery worker运行在后台而不是终端上,在后台以守护进程的方式运行,我们可以使用supervisor ...

  3. Scala进阶之路-进程控制之执行shell脚本

    Scala进阶之路-进程控制之执行shell脚本 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 废话不多说,我这里直接放一个案例. /* @author :yinzhengjie ...

  4. supervisor 管理 celery

    安装supervisor [root@ipv6-api ~]# pip3 install  supervisor 生成配置文件 [root@ipv6-api ~]#echo_supervisord_c ...

  5. Linux开机启动时执行脚本的方法

    方法 1 – 使用 rc.local利用 /etc/ 中的 rc.local 文件在启动时执行脚本与命令.我们在文件中加上一行来执行脚本,这样每次启动系统时,都会执行该脚本.不过我们首先需要为 /et ...

  6. 高版本teamview的成为被控制端时,会一直出现“正在初始化显示参数”

    故障现象:高版本teamview的成为被控制端时,控制端会一直出现“正在初始化显示参数”,如图是teamview13作为服务器端,控制端连接一直出现这个情况 做好的解决办法: 把被控制端的teamvi ...

  7. celery和supervisor配合使用,实现supervisor管理celery进程

    在这里我选择redis作为celery异步任务的中间人,系统选择CentOS6.5 64位.redis.celery和supervisor的安装参见官方文档. 安装完毕后: 1, 创建celery的实 ...

  8. css控制打印时只显示指定区域

      CreateTime--2017年9月26日08:16:04 Author:Marydon css控制打印时只显示指定区域 思路: 1.使用打印命令@media print: 2.控制执行打印命令 ...

  9. WinCE C#程序,控制启动时仅仅能启动一个程序,使用相互排斥量来实现,该实现方法測试通过

    </pre><pre code_snippet_id="430174" snippet_file_name="blog_20140718_5_46349 ...

随机推荐

  1. float,double和decimal的精度问题

    先标注一个音标,因为我老是读错:decimal ['desɪml] 精度对比: 类型 CTS 类型 描述 有效数字 范围 float System.Single 32-bit single-preci ...

  2. centos6.5安装fpm打包工具

    FPM功能简单说就是将一种类型的包转换成另一种类型.FPM的github:https://github.com/jordansissel/fpm 1.支持的源类型包: dir: 将目录打包成所需要的类 ...

  3. ADO.NET笔记——将DataReader作为函数返回值

    相关知识: 在很多情况下,可能把数据库的访问封装到一个函数中,通过该函数返回一个DataReader对象给调用者.例如定义函数:SqlDataReader returnDR(),然后再Main函数中调 ...

  4. JQuery 表格 隔行换色 和鼠标滑过的样式

    $(document).ready(function () { $(".Pub_TB tbody tr:even td").css("background-color&q ...

  5. 【Qt】Qt之设置QWidget背景色【转】

    简述 QWidget是所有用户界面对象的基类,这意味着可以用同样的方法为其它子类控件改变背景颜色. Qt中窗口背景的设置,下面介绍三种方法. 使用QPalette 使用Style Sheet 绘图事件 ...

  6. WPF 类型“System.ComponentModel.ISupportInitialize”在未被引用的程序集中定义。

    问题:类型“System.ComponentModel.ISupportInitialize”在未被引用的程序集中定义.必须添加对程序集“System, Version=4.0.0.0, Cultur ...

  7. 修改linux命令行提示符

    安装了ubuntu1304版本,发现命令行@后面的名称太长,影响视觉美观,决定修改一下.修改当前用户目录下面的.bashrc文件即可达到目的. 打开.bashrc文件,找到下面的内容:if [ &qu ...

  8. ERROR 1005 (HY000): Can't create table'matrix.system_log' (errno: 150)

    CREATE TABLE `user` (`id` bigint(32) NOT NULL AUTO_INCREMENT ,`name` varchar(32) CHARACTER SET utf8 ...

  9. 类的const成员

    类的const成员包括const数据成员和const成员函数: 1.const数据成员: 和普通的const变量一样,定义时初始化,且不能修改 2.const成员函数: const成员函数只能访问其他 ...

  10. Java 集合类(一)

    今天我们先讲一下Collection: Collection和Collections的区别: java.util.Collection是一种java集合接口,它提供了对集合对象的基本操作通用接口方法, ...