当前位置:论坛首页 > Linux面板 > 讨论

SuperVisord使用进程守护管理器,通过SHELL脚本重启检测URL脚本

发表在 Linux面板5 天前 [复制链接] 0 77

  1. #!/bin/bash

  2. echo "重启[api]!"

  3. /www/server/panel/pyenv/bin/supervisorctl restart api:api_00
  4. # curl http://127.0.0.1:7001/

  5. echo "验证[api]!"


  6. #设置变量,url为你需要检测的目标网站的网址(IP或域名)
  7. url=http://127.0.0.1:7002/
  8. declare -i status_code=-1

  9. #定义函数check_http:
  10. #使用curl命令检查http服务器的状态
  11. #-m设置curl不管访问成功或失败,最大消耗的时间为5秒,5秒连接服务为相应则视为无法连接
  12. #-s设置静默连接,不显示连接时的连接速度、时间消耗等信息
  13. #-o将curl下载的页面内容导出到/dev/null(默认会在屏幕显示页面内容)
  14. #-w设置curl命令需要显示的内容%{http_code},指定curl返回服务器的状态码
  15. check_http(){
  16.     status_code=$(curl -m 5 -s -o /dev/null -w %{http_code} $url)
  17. }

  18. while :

  19. do
  20.    check_http
  21.    
  22.     # date=$(date +%Y%m%d-%H:%M:%S)

  23.    
  24.        if [ $status_code -ne 200 ];then
  25.             echo "$url $status_code !"
  26.               # mail -s Warning root < /tmp/http$.pid
  27.        else
  28.             echo "$url $status_code 启动成功 ^_^"
  29.             break
  30.        fi
  31.        sleep 1


  32. done

复制代码


使用道具 举报 只看该作者 回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

立即付费处理

工作时间:09:00至24:00

快速回复 返回顶部 返回列表