千家信息网

安装supervisor

发表于:2024-11-15 作者:千家信息网编辑
千家信息网最后更新 2024年11月15日,1、supervisor安装文件,安装命令为:sh supervisor_install.sh#!/bin/bashyum -y install python-setuptoolseasy_insta
千家信息网最后更新 2024年11月15日安装supervisor

1、supervisor安装文件,安装命令为:sh supervisor_install.sh

#!/bin/bashyum -y install python-setuptoolseasy_install 'supervisor==3.3.4'echo "alias 'supervisorctl'='supervisorctl -c /opt/superctl/etc/supervisor.conf'" >> ~/.bashrcmkdir -p /opt/superctl/bin/mkdir -p /opt/superctl/log/mkdir -p /opt/superctl/etc/chmod -R 755 /opt/superctl/bin/chmod  755 /opt/superctl/supervisor.shcd /opt/superctl/etc/cat > supervisor.conf << EOF[unix_http_server]file=/opt/superctl/log/supervisord.sock[inet_http_server]port=127.0.0.1:9001[supervisord]logfile=/opt/superctl/log/supervisord.loglogfile_maxbytes=20MBlogfile_backups=10loglevel=infopidfile=/opt/superctl/log/supervisord.pidnodaemon=falseminfds=60000minprocs=200#directory=/opt/superctl/childlogdir=/opt/superctl/log/[rpcinterface:supervisor]supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]serverurl=unix:///opt/superctl/log/supervisord.sock ; use a unix:// URL  for a unix socket[include]files = /opt/superctl/etc/*.supervisorEOFcat > test.supervisor.temple << EOF[program:test]command = /bin/bash /opt/superctl/bin/test_start.shautostart = trueautorestart = truestdout_logfile = /opt/superctl/log/test-stdout.logstderr_logfile = /opt/superctl/log/test-stderr.logstdout_logfile_maxbytes = 500MBstdout_logfile_backups = 50stdout_capture_maxbytes = 1MBstdout_events_enabled = falseloglevel = infopriority = 1stopasgroup = trueEOF

2、在superctl目录下添加supervisor.sh文件

## chkconfig: 2345 12 80# 配置文件:/opt/superctl/etc/supervisor.conf# source ~/.bashrcPATH=/sbin:/usr/sbin:$PATHusage (){        echo $"Usage: $0 {start|stop|status|restart}" 1>&2        RETVAL=2}start (){  if [ -e /opt/superctl/etc/supervisor.conf ] ;then       if [ `ps -ef|grep "/opt/superctl/etc/supervisor.conf"|grep -v grep|wc -l` -ne 0 ];then                         sleep 1                   echo "/opt/superctl/etc/supervisor.conf 进程正在运行"                   ps -ef|grep " /opt/superctl/etc/supervisor.conf"|grep -v grep                else                         sleep 1                    /bin/supervisord -c /opt/superctl/etc/supervisor.conf        fi  fi}stop (){if [ `ps -ef|grep " /opt/superctl/etc/supervisor.conf"|grep -v grep|wc -l` -eq 1 ];then         supervisorctl stop all         sleep 4         /bin/supervisorctl shutdownfi}status (){/bin/supervisorctl status}restart (){        stop        sleep 3        start}case "$1" in    stop) stop ;;    status) status ;;    restart) restart ;;    start) start ;;    *) usage ;;esacexit $RETVA

3、启动命令:
sh supervisor.sh start|stop|restart

0