安装supervisor方法,可以直接用 yum install supervisord ,但是版本可能会旧一点,可以参考官方的方法:

easy_install supervisor

http://supervisord.org/installing.html#installing-to-a-system-with-internet-access

加入service, vim /etc/init.d/supervisord , 修改文件属性为可执行chmod 777 /etc/init.d/supervisord

#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
#
# chkconfig:
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
# processname: supervisord
# config: /etc/supervisord.conf
# pidfile: /var/run/supervisord.pid
# # source function library
. /etc/rc.d/init.d/functions # source system settings
[ -e /etc/sysconfig/supervisord ] && . /etc/sysconfig/supervisord RETVAL= start() {
echo "Starting supervisord: "
if [ -e $PIDFILE ]; then
echo "ALREADY STARTED"
return
fi # start supervisord with options from sysconfig (stuff like -c)
/usr/bin/supervisord $OPTIONS # show initial startup status
/usr/bin/supervisorctl $OPTIONS status # only create the subsyslock if we created the PIDFILE
[ -e $PIDFILE ] && touch /var/lock/subsys/supervisord
} stop() {
echo -n "Stopping supervisord: "
/usr/bin/supervisorctl $OPTIONS shutdown
if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then
echo "Waiting roughly 60 seconds for $PIDFILE to be removed after child processes exit"
for sleep in last; do
if [ ! -e $PIDFILE ] ; then
echo "Supervisord exited as expected in under $total_sleep seconds"
break
else
if [[ $sleep -eq "last" ]] ; then
echo "Supervisord still working on shutting down. We've waited roughly 60 seconds, we'll let it do its thing from here"
return
else
sleep $sleep
total_sleep=$(( $total_sleep + $sleep ))
fi fi
done
fi # always remove the subsys. we might have waited a while, but just remove it at this point.
rm -f /var/lock/subsys/supervisord
} restart() {
stop
start
} case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
restart
RETVAL=$?
;;
reload)
/usr/bin/supervisorctl $OPTIONS reload
RETVAL=$?
;;
condrestart)
[ -f /var/lock/subsys/supervisord ] && restart
RETVAL=$?
;;
status)
/usr/bin/supervisorctl $OPTIONS status
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit
esac exit $RETVAL

配置一下,echo_supervisord_conf > /etc/supervisord.conf

加入gearman的任务,下面是百度云推送的任务

vim /etc/supervisord.conf

[program:APNS_PUSH]
command=/usr/bin/php /data2/www/web/apns/worker_origin.php
process_name=APNS_PUSH_%(process_num)s
numprocs=
autostart=true
autorestart=true
user=nginx
stdout_logfile=/data2/log/push/push_%(process_num)s.log
stderr_logfile=/data2/log/push/push.error.log

下面先启动gearman,启动supervisord,ps -ef |grep xxx 查看一下任务有没有执行

另外,也可以使用gearman-monitor来查看gearman任务状态

supervisor监控gearman任务的更多相关文章

  1. [erlang]supervisor(监控树)的重启策略

    1. init函数 init() -> {ok, {SupFlags, [ChildSpec,...]}} | ignore. [ChildSpec,...] 是在init之后默认要启动的子进程 ...

  2. 使用supervisor监控进程

    在linux下监控进程,可以使用inittab,最近找到了supervisor,也很好用,记录一下:1.系统要安装python,并安装与之对应的setuptools,下载地址在此2.安装:# sh s ...

  3. nodemon 或者 Supervisor 监控 Express4.x的代码改动

    Express 4.x 默认将启动模块分离到了./bin/www中,直接使用 supervisor/nodemon 无法正常监控应用,使得开发过程中的调试非常不方便.所以我们直接把./bin/www中 ...

  4. [Erlang13]怎么把一个普通的进程挂入Supervisor监控树?

    简单来说:应该是在调用的start_link返回一个{ok,Pid}就可以把这个进程放入监控树Supervisor里面: -module(worker). -author("zhongwen ...

  5. Python学习笔记【Supervisor】:使用Supervisor监控Tornado进程

    Linux常见应用服务配置模式nginx和supervisor:采用主配置文件+项目配置文件 安装(如果使用pip安装注意看是否需要指定使用python2版本) 第一步:在Linux中使用apt-ge ...

  6. supervisor 监控redis & mongodb

    安装 安装python brew install python 安装pipwget https://bootstrap.pypa.io/get-pip.pysudo python get-pip.py ...

  7. 分布式的任务分发框架-Gearman

    官方文档:http://gearman.org/getting-started/ 安装方法和示例都有,可以详细看一下. Gearman是一个分发任务的程序框架,可以用在各种场合,与Hadoop相比,G ...

  8. 【supervisor】监控服务

    写了一个ftp服务,用supervisor监控一下 1.先写一个配置文件,路径和名称为/etc/supervisord.conf.d/ftp-server.ini [program:ftp-serve ...

  9. 关于supervisor无法监控golang代码的解决方法

    之前一直都是使用如下方式运行go代码 # go run test.go 这种运行方式是直接编译运行go代码,虽然在调试的时候没出什么问题,但是在使用supervisor监控的时候,会提示如下错误:(b ...

随机推荐

  1. 去除inline-block之间的间隙

    在使用display: inline-block;时,这些inline-block之间会有间隙,根据无双 - <去除inline-block元素间的空隙>的说法,这个间隙是4px或者8px ...

  2. linux下如何开启oracle服务和开启监听

    su - oracle  切换到oracle用户模式下 sqlplus /nolog  //登录sqlplus SQL> connect /as sysdba  //连接oracle SQL&g ...

  3. 斯坦福第三课:线性代数回顾(Linear Algebra Review)

    3.1  矩阵和向量 3.2  加法和标量乘法 3.3  矩阵向量乘法 3.4  矩阵乘法 3.5  矩阵乘法的性质 3.6  逆.转置 3.1  矩阵和向量 如图:这个是 4×2 矩阵,即 4 行  ...

  4. Valid Sudoku leetcode

    Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be ...

  5. Xcode配置.pch文件

    --到Xcode7都可以这么解决.亲测. 发现一个好东西.就是这个.pch文件.我的理解是他里面存放了我们在各个controller里面需要的头文件,那这样一来,就免去了在不同的ViewControl ...

  6. 一步一步搭建客服系统 (4) 客户列表 - JS($.ajax)调用WCF 遇到的各种坑

    本文以一个生成.获取“客户列表”的demo来介绍如何用js调用wcf,以及遇到的各种问题. 1 创建WCF服务 1.1 定义接口 创建一个接口,指定用json的格式:   [ServiceContra ...

  7. 微软BI 之SSIS 系列 - Precedence Constraint 详解优先约束的使用

    开篇介绍 Precedence Constraint 优先约束 - 在控制流中使用,用来链接控制流中各种 Task,Container,并且要求满足一定的条件才能执行相关联的 Task 或者 Cont ...

  8. 你在用什么思想编码:事务脚本 OR 面向对象?

    最近在公司内部做技术交流的时候,说起技能提升的问题,调研大家想要培训什么,结果大出我意料,很多人想要培训:面向对象编码.于是我抛出一个问题:你觉得我们现在的代码是面向对象的吗?有人回答:是,有人回答否 ...

  9. jenkins2 pipeline实例

    比较完整的实例,使用了maven打包,git tag,发通知邮件,等待用户deploy,deploy到nexus. 文章来自:http://www.ciandcd.com文中的代码来自可以从githu ...

  10. 使用Gradle运行集成测试

    如果Gradle构建的项目是一个web项目的话,里面可能包含一些集成测试和功能性测试.这些测试和单元测试不同之处是在运行之前要先在本地将web服务启动起来,并且跑完测试后能够自动的关闭web服务. 在 ...