运维脚本集
定时备份脚本
查看进程OOM分数
程序自动拉起
API调用-Shell
Python调用
Golang调用
K8S镜像下载
本文档使用MrDoc发布
返回首页
-
+
程序自动拉起
2022年5月6日 10:51
admin
###检测脚本 vim /opt/auto.sh =========================================================== #!/bin/bash while true do #ETCD服务(注意修改端口) ETCD_PORT=2179 ETCD_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${ETCD_PORT}$" | wc -l` if [ $ETCD_STATUS -eq 0 ];then cd /opt/communication/etcd;bash start.sh fi #REDIS服务(注意修改端口) REDIS_PORT=6380 REDIS_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${REDIS_PORT}$" | wc -l` if [ $REDIS_STATUS -eq 0 ];then /opt/redis/bin/redis-server /opt/redis/conf/redis.conf fi #XXL_JOB_TOMCAT服务(注意修改端口) XXL_JOB_TOMCAT_PORT=8023 XXL_JOB_TOMCAT_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${XXL_JOB_TOMCAT_PORT}$" | wc -l` if [ $XXL_JOB_TOMCAT_STATUS -eq 0 ];then cd /opt/apache-tomcat-9.0.58/bin;/bin/bash startup.sh fi #TTS_SERVER服务(注意修改端口) TTS_SERVER_PORT=7999 TTS_SERVER_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${TTS_SERVER_PORT}$" | wc -l` if [ $TTS_SERVER_STATUS -eq 0 ];then cd /opt/communication/tts_server;sh start.sh fi #PUSH_GATEWAY服务(注意修改端口) PUSH_GATEWAY_PORT=7779 PUSH_GATEWAY_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${PUSH_GATEWAY_PORT}$" | wc -l` if [ $PUSH_GATEWAY_STATUS -eq 0 ];then cd /opt/communication/push_gateway_v2;sh start.sh fi #RECORD_UPLOAD服务(注意修改端口) RECORD_UPLOAD_STATUS=`ps -ef | grep -w "record_upload" | grep -v "grep" | wc -l` if [ $RECORD_UPLOAD_STATUS -eq 0 ];then cd /opt/communication/record_upload;sh start.sh fi #CALLCENTER服务(注意修改端口) #CALLCENTER_PORT=9201 CALLCENTER_STATUS=`ps -ef | grep -E "callcenter" | grep -v grep | wc -l` if [ $CALLCENTER_STATUS -eq 0 ];then cd /opt/communication/callcenter;sh start.sh fi #SWITCH服务(注意修改端口) SWITCH_PORT=5060 SWITCH_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${SWITCH_PORT}$" | wc -l` if [ $SWITCH_STATUS -eq 0 ];then cd /opt/d9cloud/communication/switch;sh start_freeswitch.sh fi #STATE_API服务(注意修改端口) STATE_API_PORT=5998 STATE_API_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${STATE_API_PORT}$" | wc -l` if [ $STATE_API_STATUS -eq 0 ];then cd /opt/communication/state_api/bin;sh start.sh fi #CALLSCHEDULESTATS服务(注意修改端口) CALLSCHEDULESTATS_STATUS=`ps -ef | grep -E "callScheduleStats" | grep -v grep | wc -l` if [ $CALLSCHEDULESTATS_STATUS -eq 0 ];then cd /opt/communication/callScheduleStats;sh start.sh fi #CALLSCHEDULEQUERY服务(注意修改端口) CALLSCHEDULEQUERY_STATUS=`ps -ef | grep -E "callScheduleQuery" | grep -v grep | wc -l` if [ $CALLSCHEDULEQUERY_STATUS -eq 0 ];then cd /opt/communication/callScheduleQuery;sh start.sh fi #REDISCLEAREXPIRED服务(注意修改端口) REDISCLEAREXPIRED_PORT=9999 REDISCLEAREXPIRED_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${REDISCLEAREXPIRED_PORT}$" | wc -l` if [ $REDISCLEAREXPIRED_STATUS -eq 0 ];then cd /opt/communication/redisClearExpired;sh start.sh fi #OPENSIPS服务(注意修改端口) OPENSIPS_PORT=7448 OPENSIPS_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${OPENSIPS_PORT}$" | wc -l` if [ $OPENSIPS_STATUS -eq 0 ];then cd /opt/d9cloud/communication/opensips;sh start.sh fi #PUBFILESVC服务(注意修改端口) PUBFILESVC_PORT=9091 PUBFILESVC_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${PUBFILESVC_PORT}$" | wc -l` if [ $PUBFILESVC_STATUS -eq 0 ];then cd /opt/d9cloud/communication/pubFileSvc;sh start.sh fi #RTPENGINE服务(注意修改端口) RTPENGINE_PORT=60000 RTPENGINE_STATUS=`netstat -nutlp | awk '{print $4}' | grep ":${RTPENGINE_PORT}$" | wc -l` if [ $RTPENGINE_STATUS -eq 0 ];then cd /opt/d9cloud/communication/rtpengine;sh start.sh fi sleep 5 done --- ###将检测脚本添加到系统自启动 chmod +x /etc/rc.local chmod +x /etc/rc.d/rc.local vim /etc/rc.local =========================================================== #添加以下内容: /bin/bash /opt/auto.sh
分享到: