Skip to content

Commit

Permalink
reload sing-box instead of restart
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Jul 7, 2024
1 parent 96564f1 commit cb4a7fe
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/runSingbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ terminateSingbox()
fi
}

reloadSingbox()
{
if kill -0 $tokill > /dev/null 2>&1; then
kill -HUP $tokill
else
runSingbox
fi
}

trap terminateSingbox SIGINT SIGTERM SIGKILL
trap reloadSingbox SIGHUP

runSingbox

Expand All @@ -32,13 +42,12 @@ do
echo "Signal received: $signal"
# Remove singnal file
rm -f signal >> /dev/null 2>&1
case ${signal} in
case ${signal} in
"stop")
terminateSingbox
;;
"restart")
terminateSingbox
runSingbox
reloadSingbox
;;
esac
fi
Expand All @@ -47,7 +56,7 @@ do
if ! kill -0 $tokill > /dev/null 2>&1; then
if [ "$signal" != "stop" ]; then
echo "Sing-Box with PID $tokill crashed. Breaking the loop..."
break
exit 1
fi
fi
done

0 comments on commit cb4a7fe

Please sign in to comment.