use supervisor instead of nohup
比如logstash ,要允许一个命令如下:
nohup bin/logstash -f confs/zabbix.conf -l zabbix.log&
比如我想停止这个进程,那么我要先ps查进程然后再kill ,而且我又不喜欢screen那种方式,那么supervisor 就是解决方案了。
supervisor 安装
yum install supervisor
chkconfig supervisord on
supervisor 配置
/etc/supervisord.conf
只要program字段
启动2个进程,直接
/etc/init.d/supervisord start
下面是我跑logstash的配置
[program:logstash-zabbix]
directory=/opt/logstash
command=/opt/logstash/bin/logstash -f /opt/logstash/confs/zabbix.conf -l /opt/logstash/logs/zabbix.log
logfile=/opt/logstash/logs/zabbix.log
log_stderr=true
[program:logstash-redis]
command=/opt/logstash/bin/logstash -f /opt/logstash/confs/read-zabbixlog.conf -l /opt/logstash/logs/read-zabbix.log
logfile=/opt/logstash/logs/read-zabbix.log
log_stderr=true
如果想重启某个进程也是非常简单,
[[email protected] ~]# supervisorctl
logstash-redis RUNNING pid 21073, uptime 0:12:28
logstash-zabbix RUNNING pid 21074, uptime 0:12:28
supervisor> help
Documented commands (type help <topic>):
========================================
EOF exit maintail quit restart start stop
clear help open reload shutdown status tail
直接restart即可。
End
熟悉了以后基本上可以告别nohup了。
时间: 2024-10-11 06:33:10