Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Oct 2009 15:11:18 +0100
From:      Alex Trull <alex@trull.org>
To:        freebsd-rc@freebsd.org, freebsd-hackers@freebsd.org
Subject:   (Ab)using rcng's features to keep rc.d-style services running should they fail.
Message-ID:  <20091004141118.GG95662@syndicate.internationalconspiracy.org>

next in thread | raw e-mail | index | archive | help

--lZZ4ablUVnt2XgAh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi all,

I realised that because portupgrade/portmaster don't always=20
cleanly restart processes that have died due to being=20
upgraded (mysqld, often!) that this was something I wanted=20
to fix.

However, I'd seen the daemontools and wasn't a fan - too=20
much to configure with weird directories and so forth and=20
while monit is very powerful it also takes too much effort=20
to do what could be so much simpler.

So why not just (ab)use the rcng system with a script ? the=20
functionality is all there already to do almost everything=20
needed. To check whether something is running and (if not!)=20
start it.

So this is my dirty hack so far - runs out of cron with=20
"2>/dev/null" every few minutes and mails me about attempted=20
startups as they happen :

#!/bin/sh
# start things that should be running
find /usr/local/etc/rc.d/ /etc/rc.d/ -type f | egrep -v '(newsyslog|devd|se=
ndmail)' | awk '{print $0" status| grep \"is not running\" && "$0" start"}'=
  | sh

Performance is not stunning, thankfuly my cpus are quite=20
idle.

real    0m1.198s
user    0m0.610s
sys     0m0.877s

(devd, newsyslog and sendmail are left out because their=20
scripts don't behave quite right.)

Initialy I used it purely for the /usr/local/etc/rc.d but I=20
had a base ntpd die on me one evening so decided to throw in=20
/etc/rc.d/ too. This script has also caught a few other=20
failures in port-installed daemons in addition to the=20
ever-common mysqld-upgraded one.

Of course it is relatively inefficient executing all those=20
scripts on a regular basis - but it works - has anyone=20
thought of cleaner/more efficient ways of doing this and=20
getting more out of the rcng framework ? Or simpler for that=20
matter.

--
Alex

--lZZ4ablUVnt2XgAh
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (FreeBSD)

iEYEARECAAYFAkrIrQUACgkQey4m6/eWxTTE4ACfbtGSQRXQt/C/tSigVQ4eoXYI
P4kAnA2CP6HV2kiU0YpdrgPeYTFUVUBN
=6r53
-----END PGP SIGNATURE-----

--lZZ4ablUVnt2XgAh--





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091004141118.GG95662>