How to check for server availability? [v9.3.1, Linux]

From: Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: How to check for server availability? [v9.3.1, Linux]
Date: 2012-05-18 11:20:19
Message-ID: CAHjZ2x5dXgi2NYrR_LNt_FwT3M3Zj=2e07xL=5-BcL_KwufmpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all.
I'd need to check from a C language program whether the server is
running or not.
I was planning to use either "PGPing PQping(const char *conninfo)" or
"ConnStatusType PQstatus(const PGconn *conn)".
I have my program running and checking from time to time whether the
connection is kicking and alive.
In order to test the things I've done the following: while the program
is waiting for input I simply restart the postgresql server.
The issue is thayt both functions return PQPING_OK and CONNECTION_OK
respectively.
When I forward the request, I get an error: "FATAL: terminating
connection due to administrator command".
How can I reliably check the server status?
TIA:

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Piotr Ciechomski 2012-05-18 11:31:56 100% cpu usage on some postmaster processes kill the complete database
Previous Message Marti Raudsepp 2012-05-18 09:55:31 Re: Re: Is EXISTS the most efficient approach for PostgreSql to check for existence of nodes in a tree?