From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 4 14:35:59 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73300106566B for ; Sun, 4 Oct 2009 14:35:59 +0000 (UTC) (envelope-from "") Received: from mail.internationalconspiracy.org (mail.internationalconspiracy.org [85.234.142.62]) by mx1.freebsd.org (Postfix) with ESMTP id 338348FC0C for ; Sun, 4 Oct 2009 14:35:59 +0000 (UTC) Received: from localhost (mail.internationalconspiracy.org [85.234.142.62]) by mail.internationalconspiracy.org (Postfix) with SMTP id 4291E20206 for ; Sun, 4 Oct 2009 15:11:22 +0100 (BST) Received: from _HOSTNAME_ (syndicate.internationalconspiracy.org [IPv6:2002:55ea:8e40::55]) by mail.internationalconspiracy.org (Postfix) with SMTP id 7B78D201F4; Sun, 4 Oct 2009 15:11:18 +0100 (BST) Received: by _HOSTNAME_ (sSMTP sendmail emulation); Sun, 4 Oct 2009 15:11:18 +0100 Date: Sun, 4 Oct 2009 15:11:18 +0100 From: Alex Trull To: freebsd-rc@freebsd.org, freebsd-hackers@freebsd.org Message-ID: <20091004141118.GG95662@syndicate.internationalconspiracy.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lZZ4ablUVnt2XgAh" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-DSPAM-Result: Innocent X-DSPAM-Processed: Sun Oct 4 15:11:21 2009 X-DSPAM-Confidence: 0.9988 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 292,4ac8ad09526101998617228 X-Mailman-Approved-At: Sun, 04 Oct 2009 14:57:19 +0000 Cc: Subject: (Ab)using rcng's features to keep rc.d-style services running should they fail. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Oct 2009 14:35:59 -0000 --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--