Programmatically determine if a relay is hibernating
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hello. What is the authoritative way to determine if a relay is hibernating? I would have thought that using the control socket would be best, but Tor seems to unlink it when it enters hibernation, so Stem does not work. There's a possible heuristic by checking if /run/tor/tor.pid exists when /run/tor/control does not, but that's fragile because it assumes that the control socket is even enabled. Parsing the logs is doable, but also quite fragile. And I could certainly parse /var/lib/tor/state, but its format is surely subject to change at any time. How do I correctly determine whether a Tor process is in hibernation? Regards, forest -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQtr8ZXhq/o01Qf/pow+TRLM+X4xgUCaZERAgAKCRAw+TRLM+X4 xshIAQCjNVgq0vBzT+MJhbn8Vetj3UObU8DinVvp3gtj9DeLKgD/aKy7N3nvCUSu zFSSFZTCR0MFxQh9TxjmYO/tKRrPoAE= =gAnQ -----END PGP SIGNATURE-----
Hi! Watch in the log for this message: |[notice] Delaying directory fetches: We are hibernating or shutting down.| | | Regards, excurso forest-relay-contact--- wrote via tor-relays:
Hello.
What is the authoritative way to determine if a relay is hibernating? I would have thought that using the control socket would be best, but Tor seems to unlink it when it enters hibernation, so Stem does not work.
There's a possible heuristic by checking if /run/tor/tor.pid exists when /run/tor/control does not, but that's fragile because it assumes that the control socket is even enabled. Parsing the logs is doable, but also quite fragile. And I could certainly parse /var/lib/tor/state, but its format is surely subject to change at any time.
How do I correctly determine whether a Tor process is in hibernation?
Regards, forest _______________________________________________ > tor-relays mailing list -- tor-relays@lists.torproject.org > To unsubscribe send an email to tor-relays-leave@lists.torproject.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hello. excurso wrote:
Watch in the log for this message:
This is fragile and assumes: 1. Logging is enabled at loglevel notice 2. The log message never changes 3. The relay is never stopped or restarted manually 4. The relay is never updated (which would trigger a restart) I'm looking for an authoritative way to determine if a relay has entered hibernation without false positives ("systemctl stop tor" will trigger that message) and without false negatives ("Log warning syslog" in torrc would break that technique). The control protocol would let me access this information, but for some reason, it is shut down when the relay is running but hibernating. Regards, forest -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQtr8ZXhq/o01Qf/pow+TRLM+X4xgUCaZT/zgAKCRAw+TRLM+X4 xpDSAPoDPKkEBpoooASbq7dJ4un6Jfc8uJcvPNPBvQf6wkpG2AEAv0FxLSrEEPp4 kDliS9ST1BxLORmY0DhqjFoUiBRHuwg= =nLAd -----END PGP SIGNATURE-----
On Sun, Feb 15, 2026 at 12:22:50AM -0000, forest-relay-contact--- via tor-relays wrote:
What is the authoritative way to determine if a relay is hibernating? I would have thought that using the control socket would be best, but Tor seems to unlink it when it enters hibernation, so Stem does not work.
Yes, you should do it by querying the control interface. Here's what my relay answers when it's hibernating: $ telnet localhost 9150 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. authenticate 250 OK getinfo accounting/hibernating 250-accounting/hibernating=hard 250 OK I just tested by configuring a controlsocket and it seems to survive hibernation too. If yours doesn't, please file a bug -- but make sure that it isn't a Stem bug first. --Roger
participants (3)
-
excurso -
forest-relay-contact@cryptolab.net -
Roger Dingledine