startPre.sh 1.2 KB
Newer Older
wafwerar's avatar
wafwerar 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 51
#!/bin/bash
#
# if enable core dump, set start count to 3, disable core dump, set start count to 20.
# set -e
# set -x

serverName="taosd"
logDir="/var/log/taos"

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

startSeqFile=${logDir}/.startSeq
recordFile=${logDir}/.startRecord

startSeq=0

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

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