supervisor 安装(本文在ubuntu下安装)
配置阿里云源
root@bogon:/etc/apt# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily
显示了一些ubuntu的版本信息,需要得到的是Codename,比如,我这里是wily
查看:http://mirrors.aliyun.com/help/ubuntu
deb http://mirrors.aliyun.com/ubuntu/ quantal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-backports main restricted universe multiverse
上面quantal 替换为Codename中:wily
root@bogon:/etc/apt# mv sources.list sources.list_bak
root@bogon:/etc/apt# vi sources.list #添加下面内容
deb http://mirrors.aliyun.com/ubuntu/ wily main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ wily-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ wily-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ wily-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ wily-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ wily main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ wily-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ wily-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ wily-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ wily-backports main restricted universe multiverse
阿里云源配置完毕
install supervisor
- apt-get install supervisor
- 配置supervisor.conf
vi supervisor.conf
[include]
files = /etc/supervisor/conf.d/*.conf #此*.conf是需要被管理进程配置文件
- 配置被管理进程
cd /etc/supervisor/conf.d/
vi test.conf
[program:test] #进行名称
dirctory=/home/aapon/abs_tomcat/bin #目录
environment=JAVA_HOME="/home/aapon/tomcat/jdk1.7.0_75",JAVA_BIN="/home/aapon/tomcat/jdk1.7.0_75/bin" #java环境变量
command=/home/aapon/abs_tomcat/bin/startup.sh run #启动命令
autostart=true #在supervisord启动的时候也自动启动
startsecs=5 #启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
autorestart=true #程序退出后自动重启
startretries=3 #启动失败自动重试次数,默认是3
user=test #用什么用户启动
supervisor 启动命令
- 启动supervisor服务 进程 sudo supervisord -c /etc/supervisor/supervisor.conf
-
启动进程
supervisor 管理tomcat进程过程遇到的坑
- 使用 supervisord 监控管理的进程必须以 nodaemon 启动,而 tomcat 的 startup.sh 脚本是daemon方式的,如果不做修改的话,supervisord 会一直报错
在 startup.sh 的最后的
exec "$PRGDIR"/"$EXECUTABLE" start "$@" 改为
exec "$PRGDIR"/"$EXECUTABLE" run "$@"
--------------------------------------------我是分割线---------------------------------
第一篇文章,这是在一位小朋友建议下写简书文档,之前都是写到某道笔记上,以后会把自己写的文章,都放到简书上,希望对大家有帮助。