Michael McConvill has brought to my attention that the proper way to
cleanly shut down a tor server is to issue SIGINT, not SIGTERM. From
the man page:
SIGINT
Tor clients behave as with SIGTERM; but Tor servers will do a
controlled slow shutdown, closing listeners and waiting 30 seconds
before exiting. (The delay can be configured with the
ShutdownWaitLength config option.)
The point of this is to notify peers that the relay is shutting down and
give them time to choose another route.
Clients will not change behaviour.
Servers will wait for ~30s when you issue "rcctl stop tor". Increase
daemon_timeout to give tor a bit more time.
Any opinions from relay operators?
Tested on an amd64 client and a (slow) armv7 bridge.
Index: Makefile
===================================================================
RCS file: /cvs/ports/net/tor/Makefile,v
retrieving revision 1.78
diff -u -p -r1.78 Makefile
--- Makefile 26 Mar 2015 21:32:30 -0000 1.78
+++ Makefile 2 Apr 2015 12:05:12 -0000
@@ -3,6 +3,7 @@
COMMENT= anonymity service using onion routing
DISTNAME= tor-0.2.6.6
+REVISION= 0
CATEGORIES= net
HOMEPAGE= https://www.torproject.org/
Index: pkg/tor.rc
===================================================================
RCS file: /cvs/ports/net/tor/pkg/tor.rc,v
retrieving revision 1.1
diff -u -p -r1.1 tor.rc
--- pkg/tor.rc 11 Mar 2011 06:49:55 -0000 1.1
+++ pkg/tor.rc 2 Apr 2015 12:05:12 -0000
@@ -3,7 +3,12 @@
# $OpenBSD: tor.rc,v 1.1 2011/03/11 06:49:55 ajacoutot Exp $
daemon="${TRUEPREFIX}/bin/tor"
+daemon_timeout=60
. /etc/rc.d/rc.subr
+
+rc_stop() {
+ pkill -INT -f "^${pexp}"
+}
rc_cmd $1