码迷,mamicode.com
首页 > 移动开发 > 详细

superviosrd进程管理

时间:2017-09-05 17:53:58      阅读:428      评论:0      收藏:0      [点我收藏+]

标签:tde   tor   --   启动脚本   keep   func   ini   efi   err   

supervisor进程管理器
---------------------------
1. 安装依赖
yum install python-setuptools-devel

2. 安装supervisor
pip install supervisor 或者 easy_install supervisor

3. 生成配置文件
echo_supervisord_conf > /etc/supervisord.conf
修改
[unix_http_server]
file=/var/run/supervisor.sock
[supervisord]
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
[include]
files = /etc/supervisord.d/*.conf

4. supervisord服务启动脚本
#!/bin/sh
#
# /etc/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/rc.d/init.d/functions

prog="supervisord"

prefix="/usr/local"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid"


start()
{
echo -n $"Starting $prog: "
###注意下面这一行一定得有-c /etc/supervisord.conf 不然修改了配置文件根本不生效!
daemon $prog_bin -c /etc/supervisord.conf --pidfile $PIDFILE
sleep 1
[ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
echo
}

stop()
{
if [ -f $PIDFILE ]
then
echo -n $"Shutting down $prog: "
[ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
echo
else
echo -n "$prog is not running"
echo
fi
}

case "$1" in

start)
start
;;

stop)
stop
;;

status)
status $prog
;;

restart)
stop
start
;;

*)
echo "Usage: $0 {start|stop|restart|status}"
;;

esac

5. 管理服务配置文件示例
#cat /etc/supervisord.d/kafka.conf
[program:zookeeper]
command=/data/elk/kafka/bin/zookeeper-server-start.sh /data/elk/kafka/config/zookeeper.properties
autostart = true
startsecs = 5
#user = root
redirect_stderr = true
stdout_logfile = /var/log/supervisord/zookeeper.log

[program:kafka]
command=/data/elk/kafka/bin/kafka-server-start.sh /data/elk/kafka/config/server.properties
autostart = true
startsecs = 5
#user = root
redirect_stderr = true
stdout_logfile = /var/log/supervisord/kafka.log

6. supervisord命令行管理工具
supervisorctl start program
supervisorctl stop program
supervisorctl restart program
supervisorctl restart all
supervisorctl status
supervisorctl reload


bootstrap.system_call_filter: false
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["127.0.0.1","192.168.50.224"]
node.max_local_storage_nodes: 2

superviosrd进程管理

标签:tde   tor   --   启动脚本   keep   func   ini   efi   err   

原文地址:http://www.cnblogs.com/zhaojonjon/p/7479563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!