Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,22 @@ do
echo "HiddenServicePort ${virtual_port} ${source_host}:${source_port}" >> "${TORRC_PATH}"
done

tor -f "${TORRC_PATH}"
# Validate the config before launching tor. An invalid config (for example a
# HiddenServicePort target that tor can't parse, which happens for apps whose
# proxy host isn't resolvable such as `network_mode: host` apps) makes tor exit
# immediately. Combined with the `restart: on-failure` policy on the tor_server
# service, docker then recreates the container roughly once a minute, forever --
# silently pinning a CPU core and thermally throttling the whole device
# (observed in the wild: 40k+ restarts over 9 days, host stuck at 95C).
#
# Retrying in place with a backoff keeps a single long-lived container and
# surfaces the error in the logs, instead of an endless container-recreation
# storm. On the happy path `--verify-config` passes instantly and `exec tor`
# makes tor PID 1 so it still receives signals cleanly on container stop.
until tor --verify-config -f "${TORRC_PATH}"
do
echo "tor-entrypoint: tor config is invalid (see errors above); retrying in 60s" >&2
sleep 60
done

exec tor -f "${TORRC_PATH}"