Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1bcdd66

Browse files
committed
Reorder pg_ctl promote after pg_ctl status
Since start/stop/restart/reload/status is a kind of standard commandset, it seems odd to insert the special-purpose "promote" in betweenthe closely related "restart" and "reload". So put it after "status"in code and documentation.Put the documentation of the -U option in some sensible place.Rewrite the synopsis sentence in help and documentation to make itless of a growing mouthful.
1 parentb7e8feb commit1bcdd66

File tree

2 files changed

+68
-64
lines changed

2 files changed

+68
-64
lines changed

‎doc/src/sgml/ref/pg_ctl-ref.sgml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PostgreSQL documentation
1212

1313
<refnamediv>
1414
<refname>pg_ctl</refname>
15-
<refpurpose>initialize, start, stop, orrestart a <productname>PostgreSQL</productname> server</refpurpose>
15+
<refpurpose>initialize, start, stop, orcontrol a <productname>PostgreSQL</productname> server</refpurpose>
1616
</refnamediv>
1717

1818
<indexterm zone="app-pg-ctl">
@@ -77,21 +77,21 @@ PostgreSQL documentation
7777

7878
<cmdsynopsis>
7979
<command>pg_ctl</command>
80-
<arg choice="plain">promote</arg>
80+
<arg choice="plain">reload</arg>
8181
<arg>-s</arg>
8282
<arg>-D <replaceable>datadir</replaceable></arg>
8383
</cmdsynopsis>
8484

8585
<cmdsynopsis>
8686
<command>pg_ctl</command>
87-
<arg choice="plain">reload</arg>
88-
<arg>-s</arg>
87+
<arg choice="plain">status</arg>
8988
<arg>-D <replaceable>datadir</replaceable></arg>
9089
</cmdsynopsis>
9190

9291
<cmdsynopsis>
9392
<command>pg_ctl</command>
94-
<arg choice="plain">status</arg>
93+
<arg choice="plain">promote</arg>
94+
<arg>-s</arg>
9595
<arg>-D <replaceable>datadir</replaceable></arg>
9696
</cmdsynopsis>
9797

@@ -190,12 +190,6 @@ PostgreSQL documentation
190190
command-line options.
191191
</para>
192192

193-
<para>
194-
In <option>promote</option> mode, the standby server that is
195-
running in the specified data directory is commanded to exit
196-
recovery and begin read-write operations.
197-
</para>
198-
199193
<para>
200194
<option>reload</option> mode simply sends the
201195
<command>postgres</command> process a <systemitem>SIGHUP</>
@@ -213,6 +207,12 @@ PostgreSQL documentation
213207
displayed.
214208
</para>
215209

210+
<para>
211+
In <option>promote</option> mode, the standby server that is
212+
running in the specified data directory is commanded to exit
213+
recovery and begin read-write operations.
214+
</para>
215+
216216
<para>
217217
<option>kill</option> mode allows you to send a signal to a specified
218218
process. This is particularly valuable for <productname>Microsoft Windows</>
@@ -396,16 +396,6 @@ PostgreSQL documentation
396396
</listitem>
397397
</varlistentry>
398398

399-
<varlistentry>
400-
<term><option>-U <replaceable class="parameter">username</replaceable></option></term>
401-
<listitem>
402-
<para>
403-
User name for the user to start the service. For domain users, use the
404-
format <literal>DOMAIN\username</literal>.
405-
</para>
406-
</listitem>
407-
</varlistentry>
408-
409399
<varlistentry>
410400
<term><option>-P <replaceable class="parameter">password</replaceable></option></term>
411401
<listitem>
@@ -426,6 +416,16 @@ PostgreSQL documentation
426416
</para>
427417
</listitem>
428418
</varlistentry>
419+
420+
<varlistentry>
421+
<term><option>-U <replaceable class="parameter">username</replaceable></option></term>
422+
<listitem>
423+
<para>
424+
User name for the user to start the service. For domain users, use the
425+
format <literal>DOMAIN\username</literal>.
426+
</para>
427+
</listitem>
428+
</varlistentry>
429429
</variablelist>
430430
</refsect2>
431431

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ typedef enum
6262
START_COMMAND,
6363
STOP_COMMAND,
6464
RESTART_COMMAND,
65-
PROMOTE_COMMAND,
6665
RELOAD_COMMAND,
6766
STATUS_COMMAND,
67+
PROMOTE_COMMAND,
6868
KILL_COMMAND,
6969
REGISTER_COMMAND,
7070
UNREGISTER_COMMAND,
@@ -126,9 +126,9 @@ static void do_init(void);
126126
staticvoiddo_start(void);
127127
staticvoiddo_stop(void);
128128
staticvoiddo_restart(void);
129-
staticvoiddo_promote(void);
130129
staticvoiddo_reload(void);
131130
staticvoiddo_status(void);
131+
staticvoiddo_promote(void);
132132
staticvoiddo_kill(pgpid_tpid);
133133
staticvoidprint_msg(constchar*msg);
134134

@@ -922,7 +922,7 @@ do_stop(void)
922922

923923

924924
/*
925-
*restart/promote/reload routines
925+
*restart/reload routines
926926
*/
927927

928928
staticvoid
@@ -1018,6 +1018,43 @@ do_restart(void)
10181018
do_start();
10191019
}
10201020

1021+
staticvoid
1022+
do_reload(void)
1023+
{
1024+
pgpid_tpid;
1025+
1026+
pid=get_pgpid();
1027+
if (pid==0)/* no pid file */
1028+
{
1029+
write_stderr(_("%s: PID file \"%s\" does not exist\n"),progname,pid_file);
1030+
write_stderr(_("Is server running?\n"));
1031+
exit(1);
1032+
}
1033+
elseif (pid<0)/* standalone backend, not postmaster */
1034+
{
1035+
pid=-pid;
1036+
write_stderr(_("%s: cannot reload server; "
1037+
"single-user server is running (PID: %ld)\n"),
1038+
progname,pid);
1039+
write_stderr(_("Please terminate the single-user server and try again.\n"));
1040+
exit(1);
1041+
}
1042+
1043+
if (kill((pid_t)pid,sig)!=0)
1044+
{
1045+
write_stderr(_("%s: could not send reload signal (PID: %ld): %s\n"),
1046+
progname,pid,strerror(errno));
1047+
exit(1);
1048+
}
1049+
1050+
print_msg(_("server signaled\n"));
1051+
}
1052+
1053+
1054+
/*
1055+
* promote
1056+
*/
1057+
10211058
staticvoid
10221059
do_promote(void)
10231060
{
@@ -1079,38 +1116,6 @@ do_promote(void)
10791116
}
10801117

10811118

1082-
staticvoid
1083-
do_reload(void)
1084-
{
1085-
pgpid_tpid;
1086-
1087-
pid=get_pgpid();
1088-
if (pid==0)/* no pid file */
1089-
{
1090-
write_stderr(_("%s: PID file \"%s\" does not exist\n"),progname,pid_file);
1091-
write_stderr(_("Is server running?\n"));
1092-
exit(1);
1093-
}
1094-
elseif (pid<0)/* standalone backend, not postmaster */
1095-
{
1096-
pid=-pid;
1097-
write_stderr(_("%s: cannot reload server; "
1098-
"single-user server is running (PID: %ld)\n"),
1099-
progname,pid);
1100-
write_stderr(_("Please terminate the single-user server and try again.\n"));
1101-
exit(1);
1102-
}
1103-
1104-
if (kill((pid_t)pid,sig)!=0)
1105-
{
1106-
write_stderr(_("%s: could not send reload signal (PID: %ld): %s\n"),
1107-
progname,pid,strerror(errno));
1108-
exit(1);
1109-
}
1110-
1111-
print_msg(_("server signaled\n"));
1112-
}
1113-
11141119
/*
11151120
*utility routines
11161121
*/
@@ -1732,17 +1737,16 @@ do_advice(void)
17321737
staticvoid
17331738
do_help(void)
17341739
{
1735-
printf(_("%s is a utility to start, stop, restart, promote, reload configuration files,\n"
1736-
"report the status of a PostgreSQL server, or signal a PostgreSQL process.\n\n"),progname);
1740+
printf(_("%s is a utility to initialize, start, stop, or control a PostgreSQL server.\n\n"),progname);
17371741
printf(_("Usage:\n"));
17381742
printf(_(" %s init[db] [-D DATADIR] [-s] [-o \"OPTIONS\"]\n"),progname);
17391743
printf(_(" %s start [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"]\n"),progname);
17401744
printf(_(" %s stop [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n"),progname);
17411745
printf(_(" %s restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n"
17421746
" [-o \"OPTIONS\"]\n"),progname);
1743-
printf(_(" %s promote [-D DATADIR] [-s]\n"),progname);
17441747
printf(_(" %s reload [-D DATADIR] [-s]\n"),progname);
17451748
printf(_(" %s status [-D DATADIR]\n"),progname);
1749+
printf(_(" %s promote [-D DATADIR] [-s]\n"),progname);
17461750
printf(_(" %s kill SIGNALNAME PID\n"),progname);
17471751
#if defined(WIN32)|| defined(__CYGWIN__)
17481752
printf(_(" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
@@ -2066,12 +2070,12 @@ main(int argc, char **argv)
20662070
ctl_command=STOP_COMMAND;
20672071
elseif (strcmp(argv[optind],"restart")==0)
20682072
ctl_command=RESTART_COMMAND;
2069-
elseif (strcmp(argv[optind],"promote")==0)
2070-
ctl_command=PROMOTE_COMMAND;
20712073
elseif (strcmp(argv[optind],"reload")==0)
20722074
ctl_command=RELOAD_COMMAND;
20732075
elseif (strcmp(argv[optind],"status")==0)
20742076
ctl_command=STATUS_COMMAND;
2077+
elseif (strcmp(argv[optind],"promote")==0)
2078+
ctl_command=PROMOTE_COMMAND;
20752079
elseif (strcmp(argv[optind],"kill")==0)
20762080
{
20772081
if (argc-optind<3)
@@ -2174,12 +2178,12 @@ main(int argc, char **argv)
21742178
caseRESTART_COMMAND:
21752179
do_restart();
21762180
break;
2177-
casePROMOTE_COMMAND:
2178-
do_promote();
2179-
break;
21802181
caseRELOAD_COMMAND:
21812182
do_reload();
21822183
break;
2184+
casePROMOTE_COMMAND:
2185+
do_promote();
2186+
break;
21832187
caseKILL_COMMAND:
21842188
do_kill(killproc);
21852189
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp