From owner-freebsd-rc@FreeBSD.ORG Wed Mar 7 21:20:33 2012 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1961A1065676 for ; Wed, 7 Mar 2012 21:20:33 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 9C15D8FC08 for ; Wed, 7 Mar 2012 21:20:29 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [IPv6:2001:8b0:151:1:fa1e:dfff:feda:c0bb]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id q27LKN8m039484 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 7 Mar 2012 21:20:24 GMT (envelope-from matthew@FreeBSD.org) X-DKIM: OpenDKIM Filter v2.5.0 smtp.infracaninophile.co.uk q27LKN8m039484 Authentication-Results: smtp.infracaninophile.co.uk/q27LKN8m039484; dkim=none (no signature); dkim-adsp=none Message-ID: <4F57D10D.1030501@FreeBSD.org> Date: Wed, 07 Mar 2012 21:20:13 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: "Randal L. Schwartz" References: <86r4x4dv1r.fsf@red.stonehenge.com> In-Reply-To: <86r4x4dv1r.fsf@red.stonehenge.com> X-Enigmail-Version: 1.3.5 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB04BA1BFB62336DCC33D9477" X-Virus-Scanned: clamav-milter 0.97.3 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Cc: rc@FreeBSD.org Subject: Re: need a shim between postgresql and pgpool startup X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2012 21:20:33 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB04BA1BFB62336DCC33D9477 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 07/03/2012 20:18, Randal L. Schwartz wrote: > [not on list... please keep me cc'ed] >=20 > Apparently, the postgresql start returns before postgresql is fully > "warmed up". The next thing I start is pgpool, and pgpool aborts if it= > can't connect to postgres. Hmmm... that could be considered a bug in the postgres rc script, or equally a bug in pgpool. > What would the best way be to insert a 2 second delay between the two > starts, or better yet, ensure pg was up before pgpool started, *without= * > editing the rc.d file from either of the ports (I hate having local mod= s > like that). >=20 > I'm thinking of adding some sort of pgpool_startpre, or maybe a shim > that uses requires postgresql and before pgpool. Can I put > pgpool_startpre() in my rc.conf file? Create a new rc script like so, and save as pgpool_prestart in ${LOCALBASE}/etc/rc.d Make it executable: ------------------------------------- #!/bin/sh # PROVIDE: pgpool_prestart # REQUIRE: postgresql # BEFORE: pgpool sleep 2 ------------------------------------- Test using rcorder(8) that it would get executed between postgresql and pgpool: rcorder /etc/rc.d/* /usr/local/etc/rc.d/* For extra credit, write a small routine that attempts to log into postgres (or otherwise establish that postgres is up and doing) and loops until it succeeds or it has reached a certain maximum number of tries. Make this a function called start_precommand() and use the run_rc_command facility so it only runs if the script is given some form of start argument. Docco on rc script functionality is in rc.subr(8) Also look at: http://www.freebsd.org/doc/en/books/porters-handbook/rc-scripts.html Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. PGP: http://www.infracaninophile.co.uk/pgpkey --------------enigB04BA1BFB62336DCC33D9477 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9X0RcACgkQ8Mjk52CukIwxjwCgioLCJNJlFTUl1rT3EKngGLel yAQAn0Q6igVeikNFVzebodv7mn1CyBcj =wynG -----END PGP SIGNATURE----- --------------enigB04BA1BFB62336DCC33D9477--