In https://trac.torproject.org/projects/tor/ticket/5525 this is mentioned for a graceful shutdown. I see the use of this signal in the tor.service file, but not in tor.initd-r6. Or is the signal INT automatically send by the start-stop-daemon ?
*** Bug 523554 has been marked as a duplicate of this bug. ***
I added two new options to init.d/tor for tor-0.2.5.8_rc-r1. One is `graceful` which is a graceful restart (like apache's graceful) and the other is `gracefulstop` (also like apache). But there appears to be a bug in openrc's start-stop-daemon. After stopping the process with start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}" I get an exit code of 0 (as expected) but openrc marks the process as crashed. I did try many variations on that command line with no joy. I'm cc-ing the openrc people.
used it today after upgrade from 0.2.4.24 to 0.2.5.8-rc - works fine. Thx.
(In reply to Toralf Förster from comment #3) > used it today after upgrade from 0.2.4.24 to 0.2.5.8-rc - works fine. > Thx. gracefulstop stops the process correctly but openrc marks it as crashed.
ping @openrc peeps. I think this is a bug in openrc. Can you verify whether I'm not just being stupid here. I'm pretty sure my initrd script at $PORTDIR/net-misc/tor/files/tor.initd-r7 is correctly written. The behavior for "graceful" is as expected. Yet for "gracefulstop" the daemon is marked "crashed." tor is brought down gracefully with SIGINT but then openrc thinks the daemon has crashed.
There's a cosmetic thing in gracefulstop() of net-misc/tor: It prints out dots in a line till tor is stopped. But now the cursor gets a carriage return (\r) but no newline (\n), so that the following command is printed over onto the line of dots.
(In reply to Toralf Förster from comment #6) > There's a cosmetic thing in gracefulstop() of net-misc/tor: > > It prints out dots in a line till tor is stopped. But now the cursor gets a > carriage return (\r) but no newline (\n), so that the following command is > printed over onto the line of dots. Sorry I'm super busy and just now looking over old bugs. Do you have a patch?
well, b/c the similar section in apache2's init script.d doesn't suffer from this rather cosmetic issue, what's about this quick&dirty solution : gracefulstop() { ebegin "Gracefully stopping Tor" ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds" start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}" rc=$? <------------- eend "done" <------------- eend $rc <------------- } :-D
(In reply to Toralf Förster from comment #8) > > rc=$? <------------- better: local rc=0
(In reply to Toralf Förster from comment #9) > (In reply to Toralf Förster from comment #8) > > > > rc=$? <------------- > better: > local rc=0 You mean just add local rc=0 at the top of gracefulstop()?
(In reply to Anthony Basile from comment #10) > (In reply to Toralf Förster from comment #9) > > (In reply to Toralf Förster from comment #8) > > > > > > rc=$? <------------- > > better: > > local rc=0 > > You mean just add local rc=0 at the top of gracefulstop()? yes, so something like this : gracefulstop() { local rc=0 ebegin "Gracefully stopping Tor" ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds" start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}" rc=$? eend "done" eend $rc }
Okay its in as follows without a rev bump so resync and test. Submit a patch next time so there's no ambiguity. Index: files/tor.initd-r7 =================================================================== RCS file: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r7,v retrieving revision 1.1 diff -u -B -r1.1 tor.initd-r7 --- files/tor.initd-r7 23 Sep 2014 23:14:00 -0000 1.1 +++ files/tor.initd-r7 23 Dec 2014 17:24:17 -0000 @@ -63,10 +63,13 @@ } gracefulstop() { + local rc=0 ebegin "Gracefully stopping Tor" ebegin "This can take up to ${GRACEFUL_TIMEOUT} seconds" start-stop-daemon -P --stop --signal INT -R ${GRACEFUL_TIMEOUT} --pidfile "${PIDFILE}" --exec /usr/bin/tor -- --PidFile "${PIDFILE}" - eend $? + rc=$? + eend "done" + eend $rc } reload() {