程序自动拉起


2022年5月6日 10:51     admin

检测脚本

  1. vim /opt/auto.sh
  2. ===========================================================
  3. #!/bin/bash
  4. while true
  5. do
  6. #ETCD服务(注意修改端口)
  7. ETCD_PORT=2179
  8. ETCD_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${ETCD_PORT}$" | wc -l`
  9. if [ $ETCD_STATUS -eq 0 ];then
  10. cd /opt/communication/etcd;bash start.sh
  11. fi
  12. #REDIS服务(注意修改端口)
  13. REDIS_PORT=6380
  14. REDIS_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${REDIS_PORT}$" | wc -l`
  15. if [ $REDIS_STATUS -eq 0 ];then
  16. /opt/redis/bin/redis-server /opt/redis/conf/redis.conf
  17. fi
  18. #XXL_JOB_TOMCAT服务(注意修改端口)
  19. XXL_JOB_TOMCAT_PORT=8023
  20. XXL_JOB_TOMCAT_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${XXL_JOB_TOMCAT_PORT}$" | wc -l`
  21. if [ $XXL_JOB_TOMCAT_STATUS -eq 0 ];then
  22. cd /opt/apache-tomcat-9.0.58/bin;/bin/bash startup.sh
  23. fi
  24. #TTS_SERVER服务(注意修改端口)
  25. TTS_SERVER_PORT=7999
  26. TTS_SERVER_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${TTS_SERVER_PORT}$" | wc -l`
  27. if [ $TTS_SERVER_STATUS -eq 0 ];then
  28. cd /opt/communication/tts_server;sh start.sh
  29. fi
  30. #PUSH_GATEWAY服务(注意修改端口)
  31. PUSH_GATEWAY_PORT=7779
  32. PUSH_GATEWAY_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${PUSH_GATEWAY_PORT}$" | wc -l`
  33. if [ $PUSH_GATEWAY_STATUS -eq 0 ];then
  34. cd /opt/communication/push_gateway_v2;sh start.sh
  35. fi
  36. #RECORD_UPLOAD服务(注意修改端口)
  37. RECORD_UPLOAD_STATUS=`ps -ef | grep -w "record_upload" | grep -v "grep" | wc -l`
  38. if [ $RECORD_UPLOAD_STATUS -eq 0 ];then
  39. cd /opt/communication/record_upload;sh start.sh
  40. fi
  41. #CALLCENTER服务(注意修改端口)
  42. #CALLCENTER_PORT=9201
  43. CALLCENTER_STATUS=`ps -ef | grep -E "callcenter" | grep -v grep | wc -l`
  44. if [ $CALLCENTER_STATUS -eq 0 ];then
  45. cd /opt/communication/callcenter;sh start.sh
  46. fi
  47. #SWITCH服务(注意修改端口)
  48. SWITCH_PORT=5060
  49. SWITCH_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${SWITCH_PORT}$" | wc -l`
  50. if [ $SWITCH_STATUS -eq 0 ];then
  51. cd /opt/d9cloud/communication/switch;sh start_freeswitch.sh
  52. fi
  53. #STATE_API服务(注意修改端口)
  54. STATE_API_PORT=5998
  55. STATE_API_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${STATE_API_PORT}$" | wc -l`
  56. if [ $STATE_API_STATUS -eq 0 ];then
  57. cd /opt/communication/state_api/bin;sh start.sh
  58. fi
  59. #CALLSCHEDULESTATS服务(注意修改端口)
  60. CALLSCHEDULESTATS_STATUS=`ps -ef | grep -E "callScheduleStats" | grep -v grep | wc -l`
  61. if [ $CALLSCHEDULESTATS_STATUS -eq 0 ];then
  62. cd /opt/communication/callScheduleStats;sh start.sh
  63. fi
  64. #CALLSCHEDULEQUERY服务(注意修改端口)
  65. CALLSCHEDULEQUERY_STATUS=`ps -ef | grep -E "callScheduleQuery" | grep -v grep | wc -l`
  66. if [ $CALLSCHEDULEQUERY_STATUS -eq 0 ];then
  67. cd /opt/communication/callScheduleQuery;sh start.sh
  68. fi
  69. #REDISCLEAREXPIRED服务(注意修改端口)
  70. REDISCLEAREXPIRED_PORT=9999
  71. REDISCLEAREXPIRED_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${REDISCLEAREXPIRED_PORT}$" | wc -l`
  72. if [ $REDISCLEAREXPIRED_STATUS -eq 0 ];then
  73. cd /opt/communication/redisClearExpired;sh start.sh
  74. fi
  75. #OPENSIPS服务(注意修改端口)
  76. OPENSIPS_PORT=7448
  77. OPENSIPS_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${OPENSIPS_PORT}$" | wc -l`
  78. if [ $OPENSIPS_STATUS -eq 0 ];then
  79. cd /opt/d9cloud/communication/opensips;sh start.sh
  80. fi
  81. #PUBFILESVC服务(注意修改端口)
  82. PUBFILESVC_PORT=9091
  83. PUBFILESVC_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${PUBFILESVC_PORT}$" | wc -l`
  84. if [ $PUBFILESVC_STATUS -eq 0 ];then
  85. cd /opt/d9cloud/communication/pubFileSvc;sh start.sh
  86. fi
  87. #RTPENGINE服务(注意修改端口)
  88. RTPENGINE_PORT=60000
  89. RTPENGINE_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${RTPENGINE_PORT}$" | wc -l`
  90. if [ $RTPENGINE_STATUS -eq 0 ];then
  91. cd /opt/d9cloud/communication/rtpengine;sh start.sh
  92. fi
  93. sleep 5
  94. done

将检测脚本添加到系统自启动

  1. chmod +x /etc/rc.local
  2. chmod +x /etc/rc.d/rc.local
  3. vim /etc/rc.local
  4. ===========================================================
  5. #添加以下内容:
  6. /bin/bash /opt/auto.sh