need a shim between postgresql and pgpool startup
Matthew Seaman
matthew at FreeBSD.org
Wed Mar 7 21:20:33 UTC 2012
On 07/03/2012 20:18, Randal L. Schwartz wrote:
> [not on list... please keep me cc'ed]
>
> 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 mods
> like that).
>
> 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
--
Dr Matthew J Seaman MA, D.Phil.
PGP: http://www.infracaninophile.co.uk/pgpkey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20120307/650cb0d6/signature.pgp
More information about the freebsd-rc
mailing list