CentOS7 安装 supervisor 配置Beego 自动启动 自动重启 也可启动Shell

1、安装 supervisor:可以用yum 或者 py,这里用yum

yum install supervisor

2、设置supervisor开机启动

systemctl enable supervisord.service

3、配置program ,就是你要跑的应用啦

cd /etc/supervisord.d/
vi cloudConsole.ini

以下是配置文件的内容

[program:cloudConsole]
directory = /data/volume/go/CloudConsole/
command = /data/volume/go/CloudConsole/CloudConsole
autostart = true
autorestart=true
startsecs = 50
startretries=5
user = root
redirect_stderr = true
stdout_logfile = /data/volume/go/log/CloudConsole.log

到这里准备工作已做完,够自信的可以reboot了。

supervisord的程序配置文件是ini ,处*女座的可以考虑将其改为 .conf 。。。

 vi /etc/supervisord.conf
#找到
[include]
files = supervisord.d/*.ini
#将其改为 *.conf 即可,如下
[include]
files = supervisord.d/*.conf

4、 supervisord常用命令

#启动
systemctl start supervisord.service

#停止
systemctl stop supervisord.service

#重启
systemctl stop supervisord.service

#以下是program相关命令
supervisorctl status                            # 状态
supervisorctl stop cloudConsole                #关闭应用
supervisorctl start cloudConsole               #启动应用
supervisorctl restart cloudConsole             #重启应用
supervisorctl reread
supervisorctl update                    #更新新的配置

5、可能出现的故障

unix:///var/run/supervisor/supervisor.sock no such file
#supervisor 还没有启动
>supervisorctl reload
error: , [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
#supervisor 还没有启动
>systemctl restart supervisord.service
Job for supervisord.service failed because the control process exited with error code. See "systemctl status supervisord.service" and "journalctl -xe" for details.

这个需要看下日志文件才知道具体的错误

>systemctl status supervisord.service
● supervisord.service - Process Monitoring and Control Daemon
   Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2019-07-09 23:14:30 CST; 33s ago
  Process: 3526 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=2)

Jul 09 23:14:29 izj6c5pz2xotjfx3poj573z systemd[1]: Starting Process Monitoring and Control Daemon...
Jul 09 23:14:30 izj6c5pz2xotjfx3poj573z supervisord[3526]: Error: The directory named as part of the path /var/log/supervisord/CloudConsole.log does not exist.
Jul 09 23:14:30 izj6c5pz2xotjfx3poj573z supervisord[3526]: For help, use /usr/bin/supervisord -h
Jul 09 23:14:30 izj6c5pz2xotjfx3poj573z systemd[1]: supervisord.service: control process exited, code=exited status=2
Jul 09 23:14:30 izj6c5pz2xotjfx3poj573z systemd[1]: Failed to start Process Monitoring and Control Daemon.
Jul 09 23:14:30 izj6c5pz2xotjfx3poj573z systemd[1]: Unit supervisord.service entered failed state.
Jul 09 23:14:30 izj6c5pz2xotjfx3poj573z systemd[1]: supervisord.service failed.

好吧这个是因为日志文件的路径不存在

你可能感兴趣的:(CentOS7 安装 supervisor 配置Beego 自动启动 自动重启 也可启动Shell)