自己后台运行程序,一般用的是screen,tmux,懒得时候就就直接nohup &
supervisor和systemctl一样,写配置都挺麻烦的,supervisor好点的是有一个web面板。
安装
apt install supervisor
supervisor配置文件一般在/etc/supervisor/supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[inet_http_server] ;HTTP服务器,提供web管理界面
port=0.0.0.0:9001 ;Web管理后台运行的IP和端口
username=zsxwz ;登录管理后台的用户名
password=123321 ;登录管理后台的密码
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
然后就可以在/etc/supervisor/conf.d/ 放进程管理 xxx.conf
[program:xxx]
command=/opt/apache-tomcat-8.0.35/bin/catalina.sh run ; 程序启动命令
directory=/root/xxx ; 路径
autostart=true ; 在supervisord启动的时候也自动启动
startsecs=10 ; 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
autorestart=true ; 程序退出后自动重启,可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启
startretries=3 ; 启动失败自动重试次数,默认是3
user=root; 用哪个用户启动进程,默认是root
priority=999 ; 进程启动优先级,默认999,值小的优先启动
redirect_stderr=true ; 把stderr重定向到stdout,默认false
stdout_logfile=/opt/apache-tomcat-8.0.35/logs/catalina.out
supervisorctl 是 supervisord的命令行客户端工具
supervisorctl status:查看所有进程的状态
supervisorctl stop es:停止es
supervisorctl start es:启动es
supervisorctl restart es: 重启es
supervisorctl update :配置文件修改后可以使用该命令加载新的配置
supervisorctl reload: 重新启动配置中的所有程序
最后于 23/08.23 15:00
被zsxwz编辑
,原因:
上一篇:
Workers 搭建azure tts在线文本转语音下一篇:
gpt爬虫