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

这样,在更改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. HttpWebResponse取不到Cookie?原来是因为被跳转了

    今天做模拟登陆的时候,发现HttpWebResponse的Cookie都为空,但是Fiddler看是有的...后来看见是302状态,才知道请求这个的时候,Response回来已经是跳转了...这样Co ...

  2. header页头内容整理

    meta标签 <meta charset="UTF-8"/> <!--视窗宽度--> <meta name="viewport" ...

  3. WPF 绑定三(绑定List中指定的字符串)

    xaml: <Window x:Class="WpfApplication1.Window3" xmlns="http://schemas.microsoft.co ...

  4. DirectoryEntry配置IIS出现ADSI Error:未知错误(0x80005000)

    目录 问题案例 原因分析 解决问题 总结 问题案例 DirectoryEntry配置IIS,在IIS6.0下运转正常,但IIS7.0下运转会出错: System.DirectoryServices.D ...

  5. uploadify 上传

    本来想做一套上传公用的组建的,里面包含文件转码等功能,看来这些都只能后来一步一步加上了,先写下来... 1,引入脚本等 @{ Layout = null; } <!DOCTYPE html> ...

  6. JQuery解析JSon

    JsonCreatet.ashx页面 JSonAnalysis.aspx测试页面 一般处理程序中使用Newtonsoft.Json来序列化json 页面使用Jquery 来解析Json数据 Jquer ...

  7. 系统中使用frameset和Iframe刷新页面session失效

    问题:Asp.net中每次刷新页面,session中保存的只就丢失 原因: 1.有些杀毒软件会去扫描web.config文件 2.程序内部有让session丢失的代码,或服务器内存不足 3.程序有框架 ...

  8. IE6和IE7的line-height和现代浏览器不一致的问题

    1.我们发现在网页中设置line-height后,现代浏览器显示正常,可是在IE6 IE7下却不能正确解析,这时需要再额外的为旧版浏览器声明: p{ line-height: 30px; *line- ...

  9. Hadoop分布式安装

    一.安装准备         1.下载hadoop,地址:http://hadoop.apache.org/,下载相应版本         2.下载JDK版本:Hadoop只支持1.6以上,地址:ht ...

  10. VC2010 MFC文档类菜单快捷键无法加载问题

    问题1. 在菜单中项中输入&Run\tF5, 运行显示Run,而不是Run F5. 问题2.在Accelerator中绑定了快捷键,但运行程序不起作用. 以上2中问题在VC++2008和VC+ ...