"pg_ctl promote" exit status
Hello
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?
Thanks
On Tue, Oct 23, 2012 at 6:39 AM, Dhruv Ahuja <dhruvahuja@gmail.com> 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?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, Oct 23, 2012 at 12:29:11PM -0400, Robert Haas wrote:
On Tue, Oct 23, 2012 at 6:39 AM, Dhruv Ahuja <dhruvahuja@gmail.com> 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]http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
[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 : titanofold@gentoo.org
GnuPG FP : 2C00 7719 4F85 FB07 A49C 0E31 5713 AA03 D1BB FDA0
GnuPG ID : D1BBFDA0
Attachments:
pg_ctl.c-exit_status.patchtext/plain; charset=utf-8Download
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 */
{
May I propose the attached patch.
Points to note and possibly discuss:
(a) Only exit codes in do_* functions have been changed.
(b) The link to, and the version of, LSB specifications has been updated.
(c) A significant change is the exit code of do_stop() on stopping a
stopped server. Previous return is 1. Proposed return is 0. If this is
accepted, I would highly suggest a mention in the Release Notes.
(d) The exit code that raised this issue was the return of promoting a
promoted server. If promotion fails because the server is running but not
as standby, should that be considered a case of starting a started service,
or an application specific failure? I am equally weighted to opt for the
former, but have proposed differently in the patch.
On 23 October 2012 17:29, Robert Haas <robertmhaas@gmail.com> wrote:
Show quoted text
On Tue, Oct 23, 2012 at 6:39 AM, Dhruv Ahuja <dhruvahuja@gmail.com> 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?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Don't think the attachment made it in the last mail. Attaching now.
On 25 January 2013 18:33, Dhruv Ahuja <dhruvahuja@gmail.com> wrote:
Show quoted text
May I propose the attached patch.
Points to note and possibly discuss:
(a) Only exit codes in do_* functions have been changed.
(b) The link to, and the version of, LSB specifications has been updated.
(c) A significant change is the exit code of do_stop() on stopping a
stopped server. Previous return is 1. Proposed return is 0. If this is
accepted, I would highly suggest a mention in the Release Notes.
(d) The exit code that raised this issue was the return of promoting a
promoted server. If promotion fails because the server is running but not
as standby, should that be considered a case of starting a started service,
or an application specific failure? I am equally weighted to opt for the
former, but have proposed differently in the patch.On 23 October 2012 17:29, Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Oct 23, 2012 at 6:39 AM, Dhruv Ahuja <dhruvahuja@gmail.com>
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?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
pg_ctl-exit_codes_v-01.patchapplication/octet-stream; name=pg_ctl-exit_codes_v-01.patchDownload
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 2a00cd2..ab2c226 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -879,7 +879,8 @@
print_msg(_(" failed\n"));
write_stderr(_("%s: could not wait for server because of misconfiguration\n"),
progname);
- exit(1);
+ /* LSB: program is not configured */
+ exit(6);
}
}
else
@@ -900,7 +901,8 @@
{
write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file);
write_stderr(_("Is server running?\n"));
- exit(1);
+ /* LSB: running stop on a service already stopped or not running */
+ exit(0);
}
else if (pid < 0) /* standalone backend, not postmaster */
{
@@ -908,7 +910,8 @@
write_stderr(_("%s: cannot stop server; "
"single-user server is running (PID: %ld)\n"),
progname, pid);
- exit(1);
+ /* LSB: unimplemented feature */
+ exit(3);
}
if (kill((pid_t) pid, sig) != 0)
@@ -1000,7 +1003,8 @@
"single-user server is running (PID: %ld)\n"),
progname, pid);
write_stderr(_("Please terminate the single-user server and try again.\n"));
- exit(1);
+ /* LSB: unimplemented feature */
+ exit(3);
}
}
@@ -1076,7 +1080,8 @@
{
write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file);
write_stderr(_("Is server running?\n"));
- exit(1);
+ /* LSB: program is not running */
+ exit(7);
}
else if (pid < 0) /* standalone backend, not postmaster */
{
@@ -1085,7 +1090,8 @@
"single-user server is running (PID: %ld)\n"),
progname, pid);
write_stderr(_("Please terminate the single-user server and try again.\n"));
- exit(1);
+ /* LSB: unimplemented feature */
+ exit(3);
}
if (kill((pid_t) pid, sig) != 0)
@@ -1116,7 +1122,8 @@
{
write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file);
write_stderr(_("Is server running?\n"));
- exit(1);
+ /* LSB: program is not running */
+ exit(7);
}
else if (pid < 0) /* standalone backend, not postmaster */
{
@@ -1124,7 +1131,8 @@
write_stderr(_("%s: cannot promote server; "
"single-user server is running (PID: %ld)\n"),
progname, pid);
- exit(1);
+ /* LSB: unimplemented feature */
+ exit(3);
}
/* If recovery.conf doesn't exist, the server is not in standby mode */
@@ -1133,7 +1141,8 @@
write_stderr(_("%s: cannot promote server; "
"server is not in standby mode\n"),
progname);
- exit(1);
+ /* LSB: reserved for application use */
+ exit(150);
}
if ((prmfile = fopen(promote_file, "w")) == NULL)
@@ -1233,10 +1242,10 @@
printf(_("%s: no server running\n"), progname);
/*
- * The Linux Standard Base Core Specification 3.1 says this should return
+ * The Linux Standard Base Core Specification 4.1 says this should return
* '3'
- * http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-ge
- * neric/iniscrptact.html
+ * http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generi
+ * c/iniscrptact.html
*/
exit(3);
}Import Notes
Resolved by subject fallback
On 1/12/13 3:30 PM, Aaron W. Swenson wrote:
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
The LSB spec doesn't say anything about a "promote" action.
And for the stop and reload actions that you tried to change, 3 is
"unimplemented".
There is an ongoing discussion about the exit status of the stop action
under <https://commitfest.postgresql.org/action/patch_view?id=1045>, so
let's keep this item about the "promote" action.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Fri, Jan 25, 2013 at 01:54:06PM -0500, Peter Eisentraut wrote:
On 1/12/13 3:30 PM, Aaron W. Swenson wrote:
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
The LSB spec doesn't say anything about a "promote" action.
And for the stop and reload actions that you tried to change, 3 is
"unimplemented".There is an ongoing discussion about the exit status of the stop action
under <https://commitfest.postgresql.org/action/patch_view?id=1045>, so
let's keep this item about the "promote" action.
You are right. Had I read a little further down, it seems that the
exit status should actually be 7.
--
Mr. Aaron W. Swenson
Gentoo Linux Developer
Email : titanofold@gentoo.org
GnuPG FP : 2C00 7719 4F85 FB07 A49C 0E31 5713 AA03 D1BB FDA0
GnuPG ID : D1BBFDA0
On 26.01.2013 23:44, Aaron W. Swenson wrote:
On Fri, Jan 25, 2013 at 01:54:06PM -0500, Peter Eisentraut wrote:
On 1/12/13 3:30 PM, Aaron W. Swenson wrote:
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
The LSB spec doesn't say anything about a "promote" action.
And for the stop and reload actions that you tried to change, 3 is
"unimplemented".There is an ongoing discussion about the exit status of the stop action
under<https://commitfest.postgresql.org/action/patch_view?id=1045>, so
let's keep this item about the "promote" action.You are right. Had I read a little further down, it seems that the
exit status should actually be 7.
Not sure if that LSB section is relevant anyway. It specifies the exit
codes for init scripts, but pg_ctl is not an init script.
- Heikki
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Heikki Linnakangas <hlinnakangas@vmware.com> wrote:
Not sure if that LSB section is relevant anyway. It specifies the
exit codes for init scripts, but pg_ctl is not an init script.
Except that when I went to the trouble of wrapping pg_ctl with an
init script which was thoroughly LSB compliant (according to my
reading) and offered it to the community, everyone said that rather
than have such a complicated script it would be better to change
pg_ctl to include that logic and exit with an LSB compliant exit
code.
-Kevin
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 1/26/13 4:44 PM, Aaron W. Swenson wrote:
You are right. Had I read a little further down, it seems that the
exit status should actually be 7.
7 is OK for "not running", but what should we use when the server is not
in standby mode? Using the idempotent argument that we are discussing
for the stop action, promoting a server that is not a standby should be
a noop and exit successfully. Not sure if that is what we want, though.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Kevin Grittner <kgrittn@ymail.com> writes:
Heikki Linnakangas <hlinnakangas@vmware.com> wrote:
Not sure if that LSB section is relevant anyway. It specifies the
exit codes for init scripts, but pg_ctl is not an init script.
Except that when I went to the trouble of wrapping pg_ctl with an
init script which was thoroughly LSB compliant (according to my
reading) and offered it to the community, everyone said that rather
than have such a complicated script it would be better to change
pg_ctl to include that logic and exit with an LSB compliant exit
code.
Right. The start and stop actions are commonly used in initscripts
so it'd be handy if the exit codes for those didn't need to be
remapped.
On the other hand, it's not at all clear to me that anyone would try
to put the promote action into an initscript, or that LSB would have
anything to say about the exit codes for such a nonstandard action
anyway.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Mon, Jan 28, 2013 at 09:46:32AM -0500, Peter Eisentraut wrote:
On 1/26/13 4:44 PM, Aaron W. Swenson wrote:
You are right. Had I read a little further down, it seems that the
exit status should actually be 7.7 is OK for "not running", but what should we use when the server is not
in standby mode? Using the idempotent argument that we are discussing
for the stop action, promoting a server that is not a standby should be
a noop and exit successfully. Not sure if that is what we want, though.
I looked at all the LSB return codes listed here and mapped them to
pg_ctl error situations:
https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
Patch attached. I did not touch the start/stop return codes.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:
pg_ctl.difftext/x-diff; charset=us-asciiDownload
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
new file mode 100644
index 9045e00..7982340
*** a/src/bin/pg_ctl/pg_ctl.c
--- b/src/bin/pg_ctl/pg_ctl.c
*************** get_pgpid(void)
*** 252,258 ****
{
write_stderr(_("%s: could not open PID file \"%s\": %s\n"),
progname, pid_file, strerror(errno));
! exit(1);
}
}
if (fscanf(pidf, "%ld", &pid) != 1)
--- 252,258 ----
{
write_stderr(_("%s: could not open PID file \"%s\": %s\n"),
progname, pid_file, strerror(errno));
! exit(6);
}
}
if (fscanf(pidf, "%ld", &pid) != 1)
*************** get_pgpid(void)
*** 264,270 ****
else
write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
progname, pid_file);
! exit(1);
}
fclose(pidf);
return (pgpid_t) pid;
--- 264,270 ----
else
write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
progname, pid_file);
! exit(6);
}
fclose(pidf);
return (pgpid_t) pid;
*************** read_post_opts(void)
*** 668,680 ****
if (optlines == NULL)
{
write_stderr(_("%s: could not read file \"%s\"\n"), progname, postopts_file);
! exit(1);
}
else if (optlines[0] == NULL || optlines[1] != NULL)
{
write_stderr(_("%s: option file \"%s\" must have exactly one line\n"),
progname, postopts_file);
! exit(1);
}
else
{
--- 668,680 ----
if (optlines == NULL)
{
write_stderr(_("%s: could not read file \"%s\"\n"), progname, postopts_file);
! exit(6);
}
else if (optlines[0] == NULL || optlines[1] != NULL)
{
write_stderr(_("%s: option file \"%s\" must have exactly one line\n"),
progname, postopts_file);
! exit(6);
}
else
{
*************** find_other_exec_or_die(const char *argv0
*** 730,736 ****
"but was not the same version as %s.\n"
"Check your installation.\n"),
target, full_path, progname);
! exit(1);
}
return found_path;
--- 730,736 ----
"but was not the same version as %s.\n"
"Check your installation.\n"),
target, full_path, progname);
! exit(5);
}
return found_path;
*************** do_start(void)
*** 813,819 ****
{
write_stderr(_("%s: could not start server: exit code was %d\n"),
progname, exitcode);
! exit(1);
}
if (do_wait)
--- 813,819 ----
{
write_stderr(_("%s: could not start server: exit code was %d\n"),
progname, exitcode);
! exit(7);
}
if (do_wait)
*************** do_start(void)
*** 835,847 ****
write_stderr(_("%s: could not start server\n"
"Examine the log output.\n"),
progname);
! exit(1);
break;
case PQPING_NO_ATTEMPT:
print_msg(_(" failed\n"));
write_stderr(_("%s: could not wait for server because of misconfiguration\n"),
progname);
! exit(1);
}
}
else
--- 835,847 ----
write_stderr(_("%s: could not start server\n"
"Examine the log output.\n"),
progname);
! exit(7);
break;
case PQPING_NO_ATTEMPT:
print_msg(_(" failed\n"));
write_stderr(_("%s: could not wait for server because of misconfiguration\n"),
progname);
! exit(6);
}
}
else
*************** do_status(void)
*** 1203,1212 ****
printf(_("%s: no server running\n"), progname);
/*
! * 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);
}
--- 1203,1210 ----
printf(_("%s: no server running\n"), progname);
/*
! * The Linux Standard Base Core Specification 3.1 says this should return '3'
! * https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
*/
exit(3);
}
*************** pgwin32_CommandLine(bool registration)
*** 1253,1259 ****
if (ret != 0)
{
write_stderr(_("%s: could not find own program executable\n"), progname);
! exit(1);
}
}
else
--- 1251,1257 ----
if (ret != 0)
{
write_stderr(_("%s: could not find own program executable\n"), progname);
! exit(5);
}
}
else
*************** pgwin32_CommandLine(bool registration)
*** 1263,1269 ****
if (ret != 0)
{
write_stderr(_("%s: could not find postgres program executable\n"), progname);
! exit(1);
}
}
--- 1261,1267 ----
if (ret != 0)
{
write_stderr(_("%s: could not find postgres program executable\n"), progname);
! exit(5);
}
}
*************** set_mode(char *modeopt)
*** 1848,1854 ****
{
write_stderr(_("%s: unrecognized shutdown mode \"%s\"\n"), progname, modeopt);
do_advice();
! exit(1);
}
}
--- 1846,1852 ----
{
write_stderr(_("%s: unrecognized shutdown mode \"%s\"\n"), progname, modeopt);
do_advice();
! exit(2);
}
}
*************** set_sig(char *signame)
*** 1880,1886 ****
{
write_stderr(_("%s: unrecognized signal name \"%s\"\n"), progname, signame);
do_advice();
! exit(1);
}
}
--- 1878,1884 ----
{
write_stderr(_("%s: unrecognized signal name \"%s\"\n"), progname, signame);
do_advice();
! exit(2);
}
}
*************** set_starttype(char *starttypeopt)
*** 1897,1903 ****
{
write_stderr(_("%s: unrecognized start type \"%s\"\n"), progname, starttypeopt);
do_advice();
! exit(1);
}
}
#endif
--- 1895,1901 ----
{
write_stderr(_("%s: unrecognized start type \"%s\"\n"), progname, starttypeopt);
do_advice();
! exit(2);
}
}
#endif
*************** main(int argc, char **argv)
*** 2026,2032 ****
"(unprivileged) user that will\n"
"own the server process.\n"),
progname);
! exit(1);
}
#endif
--- 2024,2030 ----
"(unprivileged) user that will\n"
"own the server process.\n"),
progname);
! exit(4);
}
#endif
*************** main(int argc, char **argv)
*** 2094,2100 ****
#else
write_stderr(_("%s: -S option not supported on this platform\n"),
progname);
! exit(1);
#endif
break;
case 't':
--- 2092,2098 ----
#else
write_stderr(_("%s: -S option not supported on this platform\n"),
progname);
! exit(3);
#endif
break;
case 't':
*************** main(int argc, char **argv)
*** 2125,2131 ****
default:
/* getopt_long already issued a suitable error message */
do_advice();
! exit(1);
}
}
--- 2123,2129 ----
default:
/* getopt_long already issued a suitable error message */
do_advice();
! exit(2);
}
}
*************** main(int argc, char **argv)
*** 2136,2142 ****
{
write_stderr(_("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind]);
do_advice();
! exit(1);
}
if (strcmp(argv[optind], "init") == 0
--- 2134,2140 ----
{
write_stderr(_("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind]);
do_advice();
! exit(2);
}
if (strcmp(argv[optind], "init") == 0
*************** main(int argc, char **argv)
*** 2160,2166 ****
{
write_stderr(_("%s: missing arguments for kill mode\n"), progname);
do_advice();
! exit(1);
}
ctl_command = KILL_COMMAND;
set_sig(argv[++optind]);
--- 2158,2164 ----
{
write_stderr(_("%s: missing arguments for kill mode\n"), progname);
do_advice();
! exit(2);
}
ctl_command = KILL_COMMAND;
set_sig(argv[++optind]);
*************** main(int argc, char **argv)
*** 2178,2184 ****
{
write_stderr(_("%s: unrecognized operation mode \"%s\"\n"), progname, argv[optind]);
do_advice();
! exit(1);
}
optind++;
}
--- 2176,2182 ----
{
write_stderr(_("%s: unrecognized operation mode \"%s\"\n"), progname, argv[optind]);
do_advice();
! exit(2);
}
optind++;
}
*************** main(int argc, char **argv)
*** 2188,2194 ****
{
write_stderr(_("%s: no operation specified\n"), progname);
do_advice();
! exit(1);
}
/* Note we put any -D switch into the env var above */
--- 2186,2192 ----
{
write_stderr(_("%s: no operation specified\n"), progname);
do_advice();
! exit(2);
}
/* Note we put any -D switch into the env var above */
*************** main(int argc, char **argv)
*** 2210,2216 ****
write_stderr(_("%s: no database directory specified and environment variable PGDATA unset\n"),
progname);
do_advice();
! exit(1);
}
if (!wait_set)
--- 2208,2214 ----
write_stderr(_("%s: no database directory specified and environment variable PGDATA unset\n"),
progname);
do_advice();
! exit(2);
}
if (!wait_set)
On 6/28/13 10:50 PM, Bruce Momjian wrote:
On Mon, Jan 28, 2013 at 09:46:32AM -0500, Peter Eisentraut wrote:
On 1/26/13 4:44 PM, Aaron W. Swenson wrote:
You are right. Had I read a little further down, it seems that the
exit status should actually be 7.7 is OK for "not running", but what should we use when the server is not
in standby mode? Using the idempotent argument that we are discussing
for the stop action, promoting a server that is not a standby should be
a noop and exit successfully. Not sure if that is what we want, though.I looked at all the LSB return codes listed here and mapped them to
pg_ctl error situations:https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
Patch attached. I did not touch the start/stop return codes.
Approximately none of these changes seem correct to me. For example,
why is failing to open the PID file 6, or failing to start the server 7?
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Mon, Jul 1, 2013 at 10:11:23AM -0400, Peter Eisentraut wrote:
On 6/28/13 10:50 PM, Bruce Momjian wrote:
On Mon, Jan 28, 2013 at 09:46:32AM -0500, Peter Eisentraut wrote:
On 1/26/13 4:44 PM, Aaron W. Swenson wrote:
You are right. Had I read a little further down, it seems that the
exit status should actually be 7.7 is OK for "not running", but what should we use when the server is not
in standby mode? Using the idempotent argument that we are discussing
for the stop action, promoting a server that is not a standby should be
a noop and exit successfully. Not sure if that is what we want, though.I looked at all the LSB return codes listed here and mapped them to
pg_ctl error situations:https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
Patch attached. I did not touch the start/stop return codes.
Approximately none of these changes seem correct to me. For example,
why is failing to open the PID file 6, or failing to start the server 7?
Well, according to that URL, we have:
6 program is not configured
7 program is not running
I just updated the pg_ctl.c comments to at least point to a valid URL
for this. I think we can just call this item closed because I am still
unclear if these return codes should be returned by pg_ctl or the
start/stop script.
Anyway, while I do think pg_ctl could pass a little more information
back about failure via its return code, I am unclear if LSB is the right
approach.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 7/1/13 12:47 PM, Bruce Momjian wrote:
Approximately none of these changes seem correct to me. For example,
why is failing to open the PID file 6, or failing to start the server 7?Well, according to that URL, we have:
6 program is not configured
7 program is not running
There is also
4 user had insufficient privilege
I just updated the pg_ctl.c comments to at least point to a valid URL
for this. I think we can just call this item closed because I am still
unclear if these return codes should be returned by pg_ctl or the
start/stop script.Anyway, while I do think pg_ctl could pass a little more information
back about failure via its return code, I am unclear if LSB is the right
approach.
Yeah, a lot of these things are unclear and not used in practice, so
it's probably better to stick to exit code 1, unless there is a clear
use case. The "status" case is different, because there the exit code
can be passed out by the init script directly.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers