1.sudo apt-get install supervisor 或 sudo pip install supervisor
2.安装完毕后,会生成/etc/supervisor/conf.d目录,在该目录下创建一个或多个文件,一个文件代表一个进程。
3.配置文件内容如下:
[program:frp]
directory=/home/edge/frp_0.30.0_linux_amd64
command=sh frp.sh
autostart=true
autorestart=true
startretries=100
redirect_stderr=true
stdout_logfile=/home/edge/frp_0.30.0_linux_amd64/out.log
4.检查supervisor状态:ps aux | grep supervisor
5.检查守护进程状态:supervisorctl
supervisorctl stop program_name 停止某个进程
supervisorctl start program_name 启动某个进程
supervisorctl restart program_name 重启某个进程
supervisorctl stop all 停止全部进程
supervisorctl reload 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程
supervisorctl update 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
5.如果没有开机启动supervisorctl,在rc.local添加/usr/bin/supervisord或在~/.config/autostart/目录下创建一个文件如gnome-terminal.desktop,
[Desktop Entry]
Type=Application
Exec=/home/test
Hidden=false
X-GNOME-Autostart-enabled=true
Name[en_US]=test
Name=test
Comment[en_US]=xdg testing
Comment=xdg testing
Type=Application
Exec=gnome-terminal
当然你也可以使用图形上面的来建立这样一个开机自启动项:System-Preferences-Startup Applications- Add