SunQuest
           PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old March 28th, 2008, 05:59 AM
Tex-Twil Tex-Twil is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 7 Tex-Twil User rank is Private First Class (20 - 50 Reputation Level)Tex-Twil User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 14 m 55 sec
Reputation Power: 0
Test if server started correctly

Hello,
I'm using Postgres 8.2 on Solaris and I need to check whether or not the server started correctly in a bash script. The problem I have is that I don't know what is the correct way to check that a postgres startup failed.

- The init.d script doesn't set the errno value so I can't get a return value

- The pg_ctl wrapper doesn't set the errno value either !

- the postgres binary sets the errno in case of a failure but the problem is that, my script is run by root so I have to su to postgres user:

Code:
su postgres -c '/opt/csw/postgresql/bin/postgres -D /var/lib/pgdata >> /var/lib/pgdata/postgresql.log 2>&1' &


and in this case, I can't get the return value from the postgres command.

What is then the correct way to check that the server started correctly ? Look for the .pid file ?

Thanks,
Tex

Reply With Quote
  #2  
Old March 28th, 2008, 06:56 AM
Tex-Twil Tex-Twil is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 7 Tex-Twil User rank is Private First Class (20 - 50 Reputation Level)Tex-Twil User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 14 m 55 sec
Reputation Power: 0
Hello,
I find two solutions.
1-
Code:
/etc/init.d/postgres status

returns 1 if the server is not running.

2- I could check for the existance of the postmaster.pid file

Tex
Comments on this post
pabloj agrees!

Reply With Quote
  #3  
Old March 28th, 2008, 09:06 AM
rski rski is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 94 rski User rank is Sergeant (500 - 2000 Reputation Level)rski User rank is Sergeant (500 - 2000 Reputation Level)rski User rank is Sergeant (500 - 2000 Reputation Level)rski User rank is Sergeant (500 - 2000 Reputation Level)rski User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 3 h 54 m 19 sec
Reputation Power: 7
Quote:
Originally Posted by Tex-Twil
Hello,
I find two solutions.
1-
Code:
/etc/init.d/postgres status

returns 1 if the server is not running.

2- I could check for the existance of the postmaster.pid file

Tex

I'm not sure if solution 2. is good, sometimes it may happen that postgres did not stop correctly, you kill it for example and postmaster.pid isin't deleted (students often do that . And the situation is postgres is not working, postmaster.pid exists.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Test if server started correctly


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway