pg_ctl: Make failure to complete operation a nonzero exit
authorPeter Eisentraut <peter_e@gmx.net>
Mon, 1 May 2017 16:10:17 +0000 (12:10 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 5 Jul 2017 17:37:08 +0000 (13:37 -0400)
If an operation being waited for does not complete within the timeout,
then exit with a nonzero exit status.  This was previously handled
inconsistently.

doc/src/sgml/ref/pg_ctl-ref.sgml
src/bin/pg_ctl/pg_ctl.c

index 71e52c4c35583c089f0132cdb8d622c35cd937ef..12fa011c4e59c92ba8755c082ba53e0a8c6fca71 100644 (file)
@@ -412,6 +412,13 @@ PostgreSQL documentation
         <command>pg_ctl</command> returns an exit code based on the
         success of the startup or shutdown.
        </para>
+
+       <para>
+        If the operation does not complete within the timeout (see
+        option <option>-t</option>), then <command>pg_ctl</command> exits with
+        a nonzero exit status.  But note that the operation might continue in
+        the background and eventually succeed.
+       </para>
       </listitem>
      </varlistentry>
 
index 0c65196bda4269495650507d474cc224bf48cb2c..4e02c4cea1a51f2eacb3ef12144f622b5470fb27 100644 (file)
@@ -840,7 +840,9 @@ do_start(void)
                break;
            case POSTMASTER_STILL_STARTING:
                print_msg(_(" stopped waiting\n"));
-               print_msg(_("server is still starting up\n"));
+               write_stderr(_("%s: server did not start in time\n"),
+                            progname);
+               exit(1);
                break;
            case POSTMASTER_FAILED:
                print_msg(_(" stopped waiting\n"));
@@ -1166,7 +1168,9 @@ do_promote(void)
        else
        {
            print_msg(_(" stopped waiting\n"));
-           print_msg(_("server is still promoting\n"));
+           write_stderr(_("%s: server did not promote in time\n"),
+                        progname);
+           exit(1);
        }
    }
    else