安装与使用 supervisor
centos下,可以使用yum install supervisor安装(有些包找不到时,可以先执行yum install epel-release安装EPEL源)
文末有安装EPEL源之后,yum报错的解决方案
supervisor的典型配置为:
[program:prog_name1]
command=/usr/bin/java -jar server.jar --spring.profiles.active=uat --server.port=8080 #按需求添加参数
directory=/home/project/prog_name1/ #先到该目录下,再执行命令。某些程序需要先跳转到对应安装目录执行
stdout_logfile=/var/log/supervisor/prog_name1.log #标准输出的日志(不包括他们程序里处理的写文件日志)
autostart=true #跟随supervisor启动
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true
执行如下命令,让supervisor的守护进程跟随系统启动
systemctl enable supervisord.service
#启动supervisor自身服务
systemctl start supervisord.service
列出服务状态:
supervisorctl status
关闭服务:
supervisorctl stop prog_name1
启动服务:
supervisorctl start prog_name2
重启服务:
supervisorctl restart prog_name1 prog_name2
supervisorctl restart all
重新加载supervisor配置:
supervisorctl reload
重新加载更新过配置文件的服务:
supervisorctl update
查看对应程序日志:
supervisorctl tail -f prog_name1
supervisor控制tomcat程序进程:
修改startup.sh配置文件,将
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
修改为:
exec "$PRGDIR"/"$EXECUTABLE" run "$@"
编写配置文件ini:
[program:location]
command=/usr/local/tomcat/location/bin/startup.sh
directory=/usr/local/tomcat/location/bin
stdout_logfile=/usr/local/tomcat/location/logs/catalina.out
stderr_logfile=/usr/local/tomcat/location/logs/catalina.out
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true
关于安装EPEL源之后,yum报错的解决方案
安装EPEL源
yum install -y epel-release
安装完成后,在/etc/yum.repos.d/目录下会多出来两个文件,这两个文件就是EPEL源的配置文件,如下:
epel.repo
epel-testing.repo
查看epel.repo文件中的内容就可以发现其中的地址指向的是:https://mirrors.fedoraproject.org/,而epel-testing.repo这个文件中的软件源的地址也是指向的是https://mirrors.fedoraproject.org/
为了加快软件安装速度,我们也可以将其更改为国内的EPEL源。
进入目录
cd /etc/yum.repos.d/
备份官方提供的EPEL源配置文件
mv epel.repo epel.repo.bak
mv epel-testing.repo epel-testing.repo.bak
下载阿里云EPEL源
wget http://mirrors.aliyun.com/repo/epel-7.repo
将epel-7.repo中的内容覆盖写入到原来的epel.repo文件中
mv epel-7.repo epel.repo
重新生成缓存
yum clean all
yum makecache
至此,EPEL源安装及更换站点完成