mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-12-16 16:36:17 +00:00
refac: some exit logic
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docker Build and Push / docker_build (push) Has been cancelled
Docker Build and Push / docker_scan (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docker Build and Push / docker_build (push) Has been cancelled
Docker Build and Push / docker_scan (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
This commit is contained in:
@@ -53,13 +53,10 @@ set_ini() {
|
||||
|
||||
stop_service() {
|
||||
echo "[WGDashboard] Stopping WGDashboard..."
|
||||
kill $runtime_pid
|
||||
exit 0
|
||||
}
|
||||
|
||||
grab_pid() {
|
||||
max_rounds="10"
|
||||
round="0"
|
||||
local max_rounds="10"
|
||||
local round="0"
|
||||
local runtime_pid=""
|
||||
|
||||
while true; do
|
||||
round=$((round + 1))
|
||||
@@ -80,6 +77,8 @@ grab_pid() {
|
||||
sleep 0.5s
|
||||
done
|
||||
|
||||
kill $runtime_pid
|
||||
exit 0
|
||||
}
|
||||
|
||||
echo "------------------------- START ----------------------------"
|
||||
@@ -218,6 +217,7 @@ start_and_monitor() {
|
||||
|
||||
[[ ! -d ${WGDASH}/src/log ]] && mkdir ${WGDASH}/src/log
|
||||
[[ ! -d ${WGDASH}/src/download ]] && mkdir ${WGDASH}/src/download
|
||||
|
||||
${WGDASH}/src/venv/bin/gunicorn --config ${WGDASH}/src/gunicorn.conf.py
|
||||
|
||||
/usr/sbin/resolvconf -u
|
||||
@@ -229,13 +229,14 @@ start_and_monitor() {
|
||||
# Wait a second before continuing, to give the python program some time to get ready.
|
||||
echo -e "\nEnsuring container continuation."
|
||||
|
||||
max_rounds="10"
|
||||
round="0"
|
||||
local max_rounds="10"
|
||||
local round="0"
|
||||
|
||||
# Hang in there for 10s for Gunicorn to get ready
|
||||
while true; do
|
||||
round=$((round + 1))
|
||||
latest_error=$(ls -t ${WGDASH}/src/log/error_*.log 2> /dev/null | head -n 1)
|
||||
|
||||
local latest_error=$(ls -t ${WGDASH}/src/log/error_*.log 2> /dev/null | head -n 1)
|
||||
|
||||
if [[ $round -eq $max_rounds ]]; then
|
||||
echo "Reached breaking point!"
|
||||
@@ -263,15 +264,8 @@ start_and_monitor() {
|
||||
tail -f "$latest_error" &
|
||||
tail_pid=$!
|
||||
|
||||
echo "Grabbing PID..."
|
||||
grab_pid &
|
||||
|
||||
wait $tail_pid
|
||||
fi
|
||||
|
||||
echo "The blocking command has been broken! Script will exit in 3 minutes... Investigate!"
|
||||
sleep 180s
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Main execution flow
|
||||
|
||||
Reference in New Issue
Block a user