Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-21 Thread Stuart Henderson
init shuts them down gracefully anyway where possible. When you have a 
misbehaving system, the fewer unnecessary processes to get in the way of a 
reboot, the better.

On 21 February 2015 07:45:13 GMT+00:00, skin...@britvault.co.uk wrote:
On 2015-02-20 Fri 18:12 PM |, Ingo Schwarze wrote:
 Craig Skinner wrote on Fri, Feb 20, 2015 at 04:41:17PM +:
 
  Changed to skip pflogd, syslogd  check /var/run/rc.d/
 
 No, we don't want it, and we have given reasons
 
 Which problem are you trying to solve?
 

OpenBSD runs great Ingo.

I guessed gracefully shutting down daemons was the decent thing to do.

Oh well. for the archives, in case there is a future need.

-- 
Sent from a phone, please excuse the formatting.



Re: [Bulk] Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-21 Thread Kevin Chadwick
On Sat, 21 Feb 2015 11:19:08 +
Stuart Henderson wrote:

 init shuts them down gracefully anyway where possible. When you have
 a misbehaving system, the fewer unnecessary processes to get in the
 way of a reboot, the better.

I've certainly had Linux hang on shutting down services more than once
and never on OpenBSD. I guess less is more, proves itself again.

Systemd may have improved the Linux shutdown with cgroups though I'm
not convinced?? (by doing even more) and it's brought all sorts of
other reliability problems to the table.



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-20 Thread Adam Thompson

On 2015-02-20 11:12 AM, Ingo Schwarze wrote:

Hi Craig,

Craig Skinner wrote on Fri, Feb 20, 2015 at 04:41:17PM +:


Changed to skip pflogd, syslogd  check /var/run/rc.d/

No, we don't want it, and we have given reasons: It makes the code
longer, more fragile, and provides no known benefit whatsoever.
Fixing the most blatant downsides does not change that.

Which problem are you trying to solve?

Yours,
   Ingo



Two daemons that would very much matter are ospfd and bgpd. Normally, 
doing a clean shutdown of bgpd is the LAST thing I want, because that 
would break BGP graceful-restart - that capability relies on BGP simply 
disappearing.  If I shut down BGPd, I withdraw all my prefixes.  A clean 
shutdown of BGP can take several minutes; only very rarely would I want 
to sit and wait for BGPd to shut down before rebooting.  (Ospfd would be 
similarly affected IIRC.)


And by the time we get to special-casing half the daemons in base, 
what's the point?  Doing a clean shutdown of nfsd (or lockd or statd) 
would be harmful to certain clients that would otherwise survive the 
nfsd reboot.  Ditto for iked, sasyncd, iscsid, ldpd, and possibly even 
ntpd (not sure about that one).


Client-server protocols are generally written to retry on, or otherwise 
be resilient to, failure; signalling shutdown when I have to kick the 
server in the head for some reason (which, yes, even happens with 
OpenBSD :-)) would be a bad thing for some to many clients.


--
-Adam Thompson
 athom...@athompso.net



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-20 Thread Ingo Schwarze
Hi Craig,

Craig Skinner wrote on Fri, Feb 20, 2015 at 04:41:17PM +:

 Changed to skip pflogd, syslogd  check /var/run/rc.d/

No, we don't want it, and we have given reasons: It makes the code
longer, more fragile, and provides no known benefit whatsoever.
Fixing the most blatant downsides does not change that.

Which problem are you trying to solve?

Yours,
  Ingo



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-20 Thread Craig Skinner
On 2015-02-17 Tue 14:24 PM |, Antoine Jacoutot wrote:
 On Tue, Feb 17, 2015 at 01:20:03PM +, Craig Skinner wrote:
  Produces (on 5.6 release) - with start up order reversed:
  
  root@box:~ 0# halt -p
  stopping package daemons: greyscanner postfix sshguard.
  stopping base daemons: cron spamlogd spamd sshd ntpd unbound nsd pflogd 
  syslogd.
  syncing disks... done
 
 I cooked a patch for that a few months ago (actually 1 year ago iirc) but we 
 decided not to go down that road for a reason I cannot recall right now.
 And I was using the information from /var/run/rc.d instead to know what to 
 shutdown exactly instead of greping /etc/rc.
 

Changed to skip pflogd, syslogd  check /var/run/rc.d/


Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.447
diff -u -p -r1.447 rc
--- rc  22 Jan 2015 19:00:24 -  1.447
+++ rc  20 Feb 2015 16:38:49 -
@@ -131,17 +131,42 @@ fill_baddynamic()
}
 }
 
-start_daemon()
+start_stop_daemon()
 {
-   local _n
-   for _n; do
-   eval _do=\${${_n}_flags}
-   if [ X${_do} != XNO ]; then
-   /etc/rc.d/${_n} start
-   fi
+   local _start_stop=$1
+   local _daemon _daemon_script
+   shift
+
+   for _daemon
+   do
+   eval _do=\${${_daemon}_flags}
+   [[ ${_do} == 'NO' ]]  continue
+
+   _daemon_script=/etc/rc.d/${_daemon}
+   [[ -e ${_daemon_script} ]] ||
+   {
+   print -n --  ${_daemon}(absent)
+   continue
+   }
+   [[ -x ${_daemon_script} ]] ||
+   {
+   print -n --  ${_daemon}(inexecutable)
+   continue
+   }
+   ${_daemon_script} ${_start_stop}
done
 }
 
+start_daemon()
+{
+   start_stop_daemon 'start' $*
+}
+
+stop_daemon()
+{
+   start_stop_daemon 'stop' $*
+}
+
 make_keys()
 {
if [ ! -f /etc/isakmpd/private/local.key ]; then
@@ -269,12 +294,26 @@ if [ X$1 = Xshutdown ]; then
while [ -n ${pkg_scripts} ]; do
_r=${pkg_scripts##* }
pkg_scripts=${pkg_scripts%%*( )${_r}}
-   [ -x /etc/rc.d/${_r} ]  /etc/rc.d/${_r} stop
+   stop_daemon ${_r}
done
echo '.'
fi
 
[ -f /etc/rc.shutdown ]  sh /etc/rc.shutdown
+
+   print -n 'stopping base daemons:'
+   set -A _daemons $(egrep start_daemon[[:blank:]][[:alnum:]] 
/etc/rc)
+   for _daemon in $(jot ${#_daemons[*]} ${#_daemons[*]} 1)
+   do
+   _daemon=${_daemons[${_daemon}]}
+   [[ ${_daemon} == 'start_daemon' ]]  continue
+   [[ -f /var/run/rc.d/${_daemon} ]] || continue
+   [[ ${_daemon} == 'pflogd' ]]  continue
+   [[ ${_daemon} == 'syslogd' ]]  continue
+   stop_daemon ${_daemon}
+   done
+   print '.'
+
else
echo single user: not running shutdown scripts
fi
@@ -513,11 +552,7 @@ rm -f /etc/rc.firsttime.run
 if [ -n ${pkg_scripts} ]; then
echo -n 'starting package daemons:'
for _r in $pkg_scripts; do
-   if [ -x /etc/rc.d/${_r} ]; then
-   start_daemon ${_r}
-   else
-   echo -n  ${_r}(absent)
-   fi
+   start_daemon ${_r}
done
echo '.'
 fi



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-20 Thread Craig Skinner
On 2015-02-20 Fri 18:12 PM |, Ingo Schwarze wrote:
 Craig Skinner wrote on Fri, Feb 20, 2015 at 04:41:17PM +:
 
  Changed to skip pflogd, syslogd  check /var/run/rc.d/
 
 No, we don't want it, and we have given reasons
 
 Which problem are you trying to solve?
 

OpenBSD runs great Ingo.

I guessed gracefully shutting down daemons was the decent thing to do.

Oh well. for the archives, in case there is a future need.


-- 
Do you cheat on your wife? asked the psychiatrist.
Who else? answered the patient.



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-17 Thread Ingo Schwarze
Hi,

Antoine Jacoutot wrote on Tue, Feb 17, 2015 at 02:24:56PM +0100:
 On Tue, Feb 17, 2015 at 01:20:03PM +, Craig Skinner wrote:

 stopping base daemons: cron spamlogd spamd sshd ntpd unbound
   nsd pflogd syslogd.
 syncing disks... done

 I cooked a patch for that a few months ago (actually 1 year ago iirc)
 but we decided not to go down that road for a reason I cannot recall
 right now.

I guess the point was that it's nothing but useless complexity.

I see how a clean shutdown might matter for, say, postgres.
But what is the point in shutting down cron, sshd, ntpd, or unbound
right before the system is going down anyway?

Shutting down stuff like pflogd and syslogd before the system
is actually going down might even be harmful.

If it turns out there are one or two base daemons where shutting
them down by running the rc.d(8) script is better than what
currently happens, those one or two could get special handling
in /etc/rc itself.  But so far, i don't remember that anybody ever
saw a specific need for any of them.

Yours,
  Ingo



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-17 Thread Antoine Jacoutot
 I see how a clean shutdown might matter for, say, postgres.
 But what is the point in shutting down cron, sshd, ntpd, or unbound
 right before the system is going down anyway?
 
 Shutting down stuff like pflogd and syslogd before the system
 is actually going down might even be harmful.
 
 If it turns out there are one or two base daemons where shutting
 them down by running the rc.d(8) script is better than what
 currently happens, those one or two could get special handling
 in /etc/rc itself.  But so far, i don't remember that anybody ever
 saw a specific need for any of them.

I fully agree.

-- 
Antoine



Re: [DIFF] /etc/rc: gracefully shut down base daemons too

2015-02-17 Thread Nick Holland

On 02/17/15 08:52, Ingo Schwarze wrote:
...

Shutting down stuff like pflogd and syslogd before the system
is actually going down might even be harmful.


you mean...like maybe when doing an upgrade where the newly installed 
binaries are not compatible with the running kernel?


Considering the number of times base daemons have been shut down by 
halting the kernel and the lack of problems caused by this?  no...I 
don't think this is a good idea at all.


Nick.