-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


On 10/01/17 23:39, Francesco Poli wrote:
> On Fri, 6 Jan 2017 11:40:20 +0100 Francesco Poli wrote:
> 
>> On Fri, 6 Jan 2017 11:05:50 +0100 Daniel Pocock wrote:
> [...]
>>> My UPS uses SNMP signalling, I wonder if that makes the daemon 
>>> shut down more slowly.
>> 
>> Maybe...
> 
> Have you determine how long should the restart action wait between 
> the stop and the start action?
> 
> The command
> 
> # systemctl stop apcupsd ; systemctl start apcupsd
> 
> should reproduce the misbehavior in your case. Can you confirm?
> 

I tried that on both a jessie and stretch system.  The bug doesn't
happen every time, although within 5 attempts in quick succession I do
get the bug


> Does
> 
> # systemctl stop apcupsd ; sleep 1 ; sleep 1 ; systemctl start 
> apcupsd
> 
> suffice to avoid experiencing the misbehavior?

I tried this:



systemctl start apcupsd && while ps -C apcupsd ; do systemctl stop
apcupsd ; sleep $DELAY ; systemctl start apcupsd ; ps -C apcupsd ||
echo FAILED ; done


for a few minutes with various $DELAY values

If $DELAY == 1 the problem occurs relatively quickly.

With $DELAY == 2, I did not see the problem in 2 minutes of looping.

> 
> Or maybe
> 
> # systemctl stop apcupsd ; sleep 2 ; sleep 2 ; systemctl start 
> apcupsd
> 
> ?
> 
> Or perhaps
> 
> # systemctl stop apcupsd ; sleep 3; sleep 3 ; systemctl start 
> apcupsd
> 
> ?
> 
> Could you please perform some tests?
> 

Based on the above testing, I suspect a 2-3 second sleep in the init
script stop  operation may be sufficient to work around the problem.

Even better than sleep, it could use the "--retry" (waiting 7 seconds
for the PID to exit):

        stop)
                echo -n "Stopping $DESC: "
                start-stop-daemon --stop --oknodo --pidfile
/var/run/apcupsd.pid --retry 7 || echo "Not Running."
                wait `cat /var/run/apcupsd.pid`
                rm -f /var/run/apcupsd.pid
                echo "$NAME."
                ;;


 or "wait":


        stop)
                echo -n "Stopping $DESC: "
                APCUPSD_PID=`cat /var/run/apcupsd.pid`
                start-stop-daemon --stop --oknodo --pidfile
/var/run/apcupsd.pid || echo "Not Running."
                wait $APCUPSD_PID
                rm -f /var/run/apcupsd.pid
                echo "$NAME."
                ;;


or the service file proposed by Christian (I'll reply about that
separately)

Regards,

Daniel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJYe0C+AAoJEGxlgOd711bE58oP/2iD76HNouCFaP5QKuT3tRfv
nP9qcNHYaf9n8FpZwYmBLTFmK6O0n2dqVeEVHQPqY0U1wfHa8eO2YAYcZ4fIXvOz
T11e+JiuzIA5Sdsat+kFcvLZD447njluOVouGq+UZAhRKSMH3alrI2ug5Z0btiRn
URfoUybpMYe5ojmA0np/2cHsicrSaS+OSjvUVQhageJ505YOMK+LU3gM3BresK1B
ceMGo9NQPxNjngT2KEanIkUrufunh17YeKyeBui6zdAazIBgRz1PkZ/ZLSQClc1M
hwzEJEYkKGKMb3LrE5mWFQk+Tw5QPWIC/3C9Uc4vBWtqX0IpVcrHyfAUkfkgjABv
14ESREtWPcPrlTVcQmLbKsUcbvAbGFx5Y5t3s7pNI5OvCJT8bXDEPCk5FH0F+82+
dDhlj39GDDsXnGiyoA23U8KX0qhU1RgkJPCFKzsEKKBYpdLBosLhJl71nPg/0pCx
5M7rIEPsq8/eX63HFcz+Z5etH1fpjEg+bN/rE8mOMY+7oZ3i4rvpmRvGWy15t1yT
6AUU49h219em2LmOkAHHjZO3oAVr4bHiLMxuwSCyB4vlbZkZRYNW7Dj/QTlt1Isb
9IodU9HLT0wP3t6Zf4gp76Qb23oCf6qtWUeSGwzydl5/ke8/0W9diLnJCEzavFrG
Ug3sTUDiv9FGqRiOm1Dr
=P94o
-----END PGP SIGNATURE-----

Reply via email to