startPre.sh 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/bin/bash
#
# if enable core dump, set start count to 3, disable core dump, set start count to 20.
# set -e
# set -x

taosd=/etc/systemd/system/taosd.service
line=`grep StartLimitBurst ${taosd}`
num=${line##*=}
#echo "burst num: ${num}"

startSeqFile=/usr/local/taos/.startSeq
recordFile=/usr/local/taos/.startRecord

startSeq=0

if [[ ! -e ${startSeqFile} ]]; then
  startSeq=0
else
  startSeq=$(cat ${startSeqFile})
fi
22

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
nextSeq=`expr $startSeq + 1`
echo "${nextSeq}" > ${startSeqFile}

curTime=$(date "+%Y-%m-%d %H:%M:%S")
echo "startSeq:${startSeq} startPre.sh exec ${curTime}, burstCnt:${num}" >> ${recordFile}


coreFlag=`ulimit -c`
echo "coreFlag: ${coreFlag}" >> ${recordFile}

if [ ${coreFlag} = "0" ];then
  #echo "core is 0"
  if [ ${num} != "20" ];then
    sed -i "s/^.*StartLimitBurst.*$/StartLimitBurst=20/" ${taosd}
    systemctl daemon-reload
    echo "modify burst count from ${num} to 20" >> ${recordFile}
  fi
fi

if [ ${coreFlag} = "unlimited" ];then
  #echo "core is unlimited"
  if [ ${num} != "3" ];then
    sed -i "s/^.*StartLimitBurst.*$/StartLimitBurst=3/" ${taosd}
    systemctl daemon-reload
    echo "modify burst count from ${num} to 3" >> ${recordFile}
  fi
fi