Re: How to check postgres running or not ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to check postgres running or not ?
Дата
Msg-id 19876.1095613927@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: How to check postgres running or not ?  (Andrew Sullivan <ajs@crankycanuck.ca>)
Ответы Re: How to check postgres running or not ?  (Andrew Sullivan <ajs@crankycanuck.ca>)
Re: How to check postgres running or not ?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-sql
Andrew Sullivan <ajs@crankycanuck.ca> writes:
> On Sun, Sep 19, 2004 at 12:25:00PM -0400, Tom Lane wrote:
>> ps aux | grep postmaster | grep -v grep
>> (or use "ps -ef" if using a SysV-ish ps).

> Except that on Solaris, ps -ef _always_ shows "postmaster", even for
> the individual back ends.

Right, but if you see a backend then you can figure the system is up.

If you are concerned about the case where the postmaster has crashed and
yet there are still backends laying about, then the whole "ps" approach
is probably wrong anyway.  It would make more sense to check whether the
postmaster is answering the doorbell --- ie, send a connection request
and see what happens.

At one time there was discussion of writing a "pg_ping" utility program
to do exactly this, but it still hasn't got done.  You can fake it to
some extent by just running "psql -l >/dev/null" and checking the exit
code, but this does require supplying a valid username and possibly a
password (because psql's exit code doesn't distinguish "could not
connect" from authentication errors).

BTW, "pg_ctl status" doesn't answer this need because it only looks for
a postmaster.pid file, it doesn't attempt to verify that the postmaster
is really alive.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: ORDER BY and NULLs
Следующее
От: T E Schmitz
Дата:
Сообщение: Re: ORDER BY and NULLs