On Tue, Oct 23, 2012 at 12:29:11PM -0400, Robert Haas wrote: > On Tue, Oct 23, 2012 at 6:39 AM, Dhruv Ahuja <[email protected]> wrote: > > The "pg_ctl promote" command returns an exit code of 1 when the server > > is not in standby mode, and the same exit code of 1 when the server > > isn't started at all. The only difference at the time being is the > > string output at the time, which FYI are... > > > > pg_ctl: cannot promote server; server is not in standby mode > > > > ...and... > > > > pg_ctl: PID file "/var/lib/pgsql/9.1/data/postmaster.pid" does not exist > > Is server running? > > > > ...respectively. > > > > I am in the process of developing a clustering solution around luci > > and rgmanager (in Red Hat EL 6) and for the time being, am basing it > > off the string output. Maybe each different exit reason should have a > > unique exit code, whatever my logic and approach to solving this > > problem be? > > That doesn't seem like a bad idea. Got a patch? >
The Linux Standard Base Core Specification 3.1 says this should return '3'. [1] [1] http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html -- Mr. Aaron W. Swenson Gentoo Linux Developer Email : [email protected] GnuPG FP : 2C00 7719 4F85 FB07 A49C 0E31 5713 AA03 D1BB FDA0 GnuPG ID : D1BBFDA0
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index e412d71..6743849 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -900,7 +900,13 @@ do_stop(void)
{
write_stderr(_("%s: PID file \"%s\" does not exist\n"),
progname, pid_file);
write_stderr(_("Is server running?\n"));
- exit(1);
+ /*
+ * The Linux Standard Base Core Specification 3.1 says this
should return
+ * '3'
+ *
http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-ge
+ * neric/iniscrptact.html
+ */
+ exit(3);
}
else if (pid < 0) /* standalone backend, not
postmaster */
{
@@ -1076,7 +1082,13 @@ do_reload(void)
{
write_stderr(_("%s: PID file \"%s\" does not exist\n"),
progname, pid_file);
write_stderr(_("Is server running?\n"));
- exit(1);
+ /*
+ * The Linux Standard Base Core Specification 3.1 says this
should return
+ * '3'
+ *
http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-ge
+ * neric/iniscrptact.html
+ */
+ exit(3);
}
else if (pid < 0) /* standalone backend, not
postmaster */
{
@@ -1116,7 +1128,13 @@ do_promote(void)
{
write_stderr(_("%s: PID file \"%s\" does not exist\n"),
progname, pid_file);
write_stderr(_("Is server running?\n"));
- exit(1);
+ /*
+ * The Linux Standard Base Core Specification 3.1 says this
should return
+ * '3'
+ *
http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-ge
+ * neric/iniscrptact.html
+ */
+ exit(3);
}
else if (pid < 0) /* standalone backend, not
postmaster */
{
pgpmyZk6PCS05.pgp
Description: PGP signature
