Date: Wed, 07 Mar 2012 21:20:13 +0000 From: Matthew Seaman <matthew@FreeBSD.org> To: "Randal L. Schwartz" <merlyn@stonehenge.com> Cc: rc@FreeBSD.org Subject: Re: need a shim between postgresql and pgpool startup Message-ID: <4F57D10D.1030501@FreeBSD.org> In-Reply-To: <86r4x4dv1r.fsf@red.stonehenge.com> References: <86r4x4dv1r.fsf@red.stonehenge.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F57D10D.1030501>