aboutsummaryrefslogtreecommitdiffstats
path: root/core/entrypoint.sh
diff options
context:
space:
mode:
Diffstat (limited to 'core/entrypoint.sh')
-rw-r--r--core/entrypoint.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/core/entrypoint.sh b/core/entrypoint.sh
index bbe05d6..47c4dd1 100644
--- a/core/entrypoint.sh
+++ b/core/entrypoint.sh
@@ -87,6 +87,19 @@ ExcludeExitNodes {US}
StrictNodes 1
EOF
tor -f /etc/tor/torrc --runasdaemon 1
-fi
-exec /usr/bin/python3 /srv/app/server.py
+ # check health tor
+ while :; do
+ checkurl=$(curl --socks5 localhost:9050 -o /dev/null -s -w "%{http_code}\n" "${URL_CHECK:-https://www.youtube.com/results?search_query=rms}")
+ if [ "$checkurl" = '502' ] || [ "$checkurl" = '302' ]; then
+ pkill tor && tor -f /etc/tor/torrc --runasdaemon 0 2>&1
+ pkill python3 && /usr/bin/python3 /srv/app/server.py
+ else
+ pgrep python3 > /dev/null || exec /usr/bin/python3 /srv/app/server.py
+ fi
+ sleep 5
+ done
+
+else
+ exec /usr/bin/python3 /srv/app/server.py
+fi