Linux中安装 supervisor 具体步骤

Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启,下面为大家分享一下在Linux中安装 supervisor 具体步骤。

1,安装python,supervisor

# apt-get install python supervisor

2,配置supervisor

# cat /etc/supervisor/conf.d/mini_breakpad.conf  
[program:minibreakpad]  //进程名称  
directory = /root/error/mini-breakpad-server //程序的启动目录  
command = node lib/app.js //启动命令  
autostart = true //在supervisord 启动的时候也自动启动  
startsecs = 5 //启动5秒后没有退出就当做已经正常启动  
autorestart = true //程序异常退出后自动重启  
startretries = 5 //启动失败自动重试次数 5  
user = root //用哪个用户启动  
redirect_stderr = true //把 stderr 重定向到 stdout 默认 false,如果是false就不需要设置下面的log配置  
stdout_logfile_maxbytes = 20MB //stdout 日志文件大小,默认50MB  
stdout_logfile_backups = 20 //stdout 日志文件备份数  
//stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)  
stdout_logfile = /root/error/mini-breakpad-server/logs/stdout.log

3,重启supervisor,查看状态

# /etc/init.d/supervisor restart  
 
# supervisorctl status  
minibreakpad                     RUNNING   pid 17655, uptime 2:57:07

注意:如果在后台运行的程序,有守护进程的,就不要用supervisor,用了nohup也不行。会报以下错误

# supervisorctl status
minibreakpad FATAL Exited too quickly (process log may have details)

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容