layout: post
title: 守護(hù)進(jìn)程之supervisor
categories: [blog]
tags: [SOA]
description:
守護(hù)進(jìn)程之supervisor
? SOA服務(wù)需要守護(hù)進(jìn)程保證服務(wù)不會(huì)掛掉,可以在Container啟動(dòng)的時(shí)候或者使用發(fā)布系統(tǒng)啟動(dòng)Damon,SOA中間件同時(shí)接收到supervisor對(duì)上一個(gè)Git Head的INT信號(hào)痕届,實(shí)現(xiàn)新的git commit的發(fā)布,這里面涉及到一個(gè)注冊(cè)中心通知服務(wù)的時(shí)間豆同。
? 這意味著土匀,可以在發(fā)布系統(tǒng)接入supervisor實(shí)現(xiàn)更好的管控周荐。
[TOC]
介紹
Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems.
安裝supervisor
brew install supervisor
sudo apt-get install supervisor
修改配置文件
sudo vim /etc/supervisord.d/arena.api.melody.ini
跳到最后一行辐脖,插入以下內(nèi)容:
[www-data@vpca-arena-api-melody-1 supervisord.d]$ cat arena.api.melody.ini
[program:arena.api.melody]
command=sh script/start_service.sh //要后臺(tái)運(yùn)行的命令[program:程序名]
autorestart=true //程序隨supervisor啟動(dòng)
process_name=arena.api.melody
numprocs=1
stopsignal=INT
directory=/data/arena.api.melody
user=www-data
redirect_stderr=true
stdout_logfile=/data/log/supervisor/arena.api.melody.out //指定標(biāo)準(zhǔn)日志輸出文件
stdout_logfile_maxbytes=100MB
stdout_logfile_backups=10
stopasgroup=true
killasgroup=true
可使用模版生成配置文件
echo_supervisord_conf > /etc/supervisord.d/servername.conf
啟動(dòng)supervisor和server
sudo service supervisor start
ps -ef | grep servername
客戶端控制
作為C/S架構(gòu)饲宛,supervisord是服務(wù)端,可以通過(guò)客戶端supervisorctl控制服務(wù)端的運(yùn)行嗜价。
sudo supervisorctl start servername
sudo supervisorctl stop servername
sudo supervisorctl restart servername
sudo supervisorctl reload
sudo supervisorctl start all