From: | Travis Hume <travis(dot)hume(at)tenzing(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Breck Thomas <Breck(dot)Thomas(at)tenzing(dot)com> |
Subject: | need a method to ping a running database |
Date: | 2003-06-11 23:35:58 |
Message-ID: | 3EE7BCDE.3010104@tenzing.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I need a shell scriptable method to determine if a postgresql database
is running and accepting connections.
I've written a script to start out postgresql database and I was using:
"pg_ctl status"
to determine if the database had been started. There are a couple of
problems with this method. It seems that if you start postgresql and
then issue a "kill -9" on the postmaster processes a .pid file is left
behind (understandable), but then if you run "pg_ctl status" it will
immediately report that the database is running and give you the pid
number and whatever else. This is a bit misleading to say the least.
To solve this problem I changed my db_ping() function to be more like
"ps ax |grep -q postmaster && pg_ctl status". This works better, but
there is still a problem.
The .pid file is being written immediately, not when the database is
actually up and accepting connections. This causes my java app to try
and open the database and setup a connection pool before it should.
I need a shell scriptable method to determine if the database is started
and ready to accept connections.
From | Date | Subject | |
---|---|---|---|
Next Message | Maksim Likharev | 2003-06-11 23:37:16 | TABLE FUNCTION, ERROR: WRONG RECORD TYPE IN RETURN NEXT |
Previous Message | Joe Conway | 2003-06-11 23:00:27 | Re: Trouble returning setof |