CentOS7安装Supervisor3.1.4

supervisord

负责管理进程的server端,配置文件是/etc/supervisor/supervisord.conf

supervisorctl

client端的命令行工具,管理子进程,配置文件在/etc/supervisor/supervisord.d/目录下

 

yum install -y supervisor

安装supervisor

(如果用的是阿里云的CentOS7会提示找不到supervisor,

则yum install epel-release先安装EPEL源)

 

systemctl enable supervisord

开机自启

 

systemctl start supervisord

启动supervisord

 

systemctl status supervisord

查看状态

 

 vim /etc/supervisord.conf

修改配置文件

开启web界面访问

把[inet_http_server]模块的注释去掉

并修改IP、用户名与密码

[inet_http_server]
port=192.168.1.108:9001

(或者0.0.0.0:9001)
username=root 
password=123456

 

supervisorctl reload

重新加载配置文件

 

开启Supervisor默认的9001端口
firewall-cmd --zone=public --add-port=9001/tcp --permanent
firewall-cmd --reload 

 

 访问

http://192.168.1.108:9001

 

cat /etc/supervisord.conf

查看配置文件最后一个模块

配置需要管理的进程

也可修改为

files = supervisord.d/*.conf后缀

目录在/etc/supervisord.d/下面

 

vim eolinker_os.ini

新增eolinker_os进程

[program:eolinker_os]
directory = /root/eolinker_os                           ;启动目录
command =  java -jar eolinker_os-4.0.jar       ;启动命令
autostart = true                                               ;在supervisord启动的时候也启动
startsecs = 5                                                   ;启动5秒后没有异常退出,就当作已经正常启动了
autorestart = true                                            ;程序异常退出后自动重启
startretries = 3                                                ;启动失败自动重试次数,默认是3
user = root                                                      ;哪个用户启动
redirect_stderr = true                                      ;把stderr重定向到stdout,默认false
stdout_logfile_maxbytes = 20MB                    ;stdout日志文件大小,默认50MB
stdout_logfile_backups = 20                           ;stdout日志文件备份数
stdout_logfile = /root/eolinker_os/logs/eolinker_os_stdout.log
;stdout日志文件,需要手动创建/root/eolinker_os/logs目录

 

supervisorctl start eolinker_os

启动eolinker_os进程

 

如果报错

FATAL     can't find command 'java'

则填写java的绝对路径

command =  /usr/local/java/bin/java -jar eolinker_os-4.0.jar

 

vim renren_fast.ini

新增reren_fast进程

[program:renren_fast]
directory = /root/renren_fast                       
command =  /usr/local/java/bin/java -jar renren-fast.jar
autostart = true                                               
startsecs = 5                                                   
autorestart = true                                            
startretries = 3                                                
user = root                                                      
redirect_stderr = true                                      
stdout_logfile_maxbytes = 20MB                    
stdout_logfile_backups = 20                           
stdout_logfile = /root/renren_fast/logs/renren_fast_stdout.log

 

supervisorctl start renren_fast

启动renren_fast进程

 

supervisorctl
> status           #查看程序状态
> stop name    #关闭name程序
> start name    #启动name程序
> restart name # 重启name程序
> reread          #读取有更新的配置文件,不会启动新添加的程序
> update          #重启配置文件修改过的程序

 

 

 或者

vim /usr/local/nginx/conf/nginx.conf

修改nginx配置文件

把80端口映射到9001端口

添加

location /supervisor/ {
        proxy_pass http://127.0.0.1:9001/;
}

 

systemctl restart nginx

重启nginx

访问

http://192.168.1.108/supervisor/

或者继续访问带端口的地址

posted @ 2018-12-22 23:30  此生不换Yang  阅读(10028)  评论(2编辑  收藏  举报