Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejun committed Aug 13, 2024
1 parent 2c64a97 commit 68ce50e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions keepalive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

installpath="$HOME"

#返回0表示成功, 1表示失败
#在if条件中,0会执行,1不会执行
checkvlessAlive() {
if ps aux | grep app.js | grep -v "grep"; then
return 0
Expand All @@ -13,22 +15,21 @@ checkvlessAlive() {
checkvmessAlive() {
local c=0
if ps aux | grep web.js | grep -v "grep" >/dev/null; then
((c + 1))
c=$((c + 1))
fi

if ps aux | grep cloud | grep -v "grep" >/dev/null; then
((c + 1))
c=$((c + 1))
fi
if ps aux | grep server.js | grep -v "grep" >/dev/null; then
((c + 1))
c=$((c + 1))
fi

echo "c=$c"
if [ $c -eq 3 ]; then
return 1
return 0
fi

return 0 # 有一个或多个进程不在运行
return 1 # 有一个或多个进程不在运行

}

Expand All @@ -38,24 +39,25 @@ if [ ! -f config.json ]; then
echo "未配置保活项目,请先行配置!" >>a.log
exit 0
fi
monitor=$(jq -r ".item[]" config.json)
monitor=($(jq -r ".item[]" config.json))
for obj in "${monitor[@]}"; do
if [ "$obj" == "vless" ]; then
if ! checkvlessAlive; then
if ! checkvlessAlive ; then
cd ${installpath}/serv00-play/vless
if ! ./start.sh; then
echo "RESPONSE:vless restarts failure."
echo "RESPONSE:vless restarted failure."
else
echo "RESPONSE:vless restarts successfully."
echo "RESPONSE:vless restarted successfully."
fi
fi
elif [ "$obj" == "vmess" ]; then
if ! checkvmessAlive; then
if ! checkvmessAlive ; then
cd ${installpath}/serv00-play/vmess
echo "start vmess"
if ! ./start.sh; then
echo "vmess restarts failure."
echo "RESPONSE:vmess restarted failure."
else
echo "vmess restarts successfully."
echo "RESPONSE:vmess restarted successfully."
fi
fi
fi
Expand Down

0 comments on commit 68ce50e

Please sign in to comment.