<arg>-U <replaceable>username</replaceable></arg>
<arg>-P <replaceable>password</replaceable></arg>
<arg>-D <replaceable>datadir</replaceable></arg>
+ <arg>-S
+ <group choice="plain">
+ <arg>a[uto]</arg>
+ <arg>d[emand]</arg>
+ </group>
+ </arg>
<arg>-w</arg>
<arg>-t <replaceable>seconds</replaceable></arg>
<arg>-o <replaceable>options</replaceable></arg>
<para>
<option>register</option> mode allows you to register a system service
- on <productname>Microsoft Windows</>.
+ on <productname>Microsoft Windows</>. The <option>-S</option> option
+ allows selection of service start type, either <quote>auto</quote> (start
+ service automatically on system startup), on <quote>demand</quote>.
</para>
<para>
Specifies the shutdown mode. <replaceable>mode</replaceable>
can be <literal>smart</literal>, <literal>fast</literal>, or
<literal>immediate</literal>, or the first letter of one of
- these three.
+ these three. If this is omitted, <literal>smart</literal> is used.
</para>
</listitem>
</varlistentry>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><option>-S <replaceable class="parameter">start-type</replaceable></option></term>
+ <listitem>
+ <para>
+ Start type of the system service to register. start-type can
+ be <literal>auto</literal>, or <literal>demand</literal>, or
+ the first letter of one of these two. If this is omitted,
+ <literal>auto</literal> is used.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect2>
static void pgwin32_doRunAsService(void);
static int CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_service);
+static DWORD pgctl_start_type = SERVICE_AUTO_START;
static SERVICE_STATUS status;
static SERVICE_STATUS_HANDLE hStatus = (SERVICE_STATUS_HANDLE) 0;
static HANDLE shutdownHandles[2];
}
if ((hService = CreateService(hSCM, register_servicename, register_servicename,
- SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
- SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
+ SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
+ pgctl_start_type, SERVICE_ERROR_NORMAL,
pgwin32_CommandLine(true),
NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL)
{
printf(_(" %s kill SIGNALNAME PID\n"), progname);
#if defined(WIN32) || defined(__CYGWIN__)
printf(_(" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
- " [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
+ " [-S START-TYPE] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s unregister [-N SERVICENAME]\n"), progname);
#endif
printf(_(" -N SERVICENAME service name with which to register PostgreSQL server\n"));
printf(_(" -P PASSWORD password of account to register PostgreSQL server\n"));
printf(_(" -U USERNAME user name of account to register PostgreSQL server\n"));
+ printf(_(" -S START-TYPE service start type to register PostgreSQL server\n"));
+
+ printf(_("\nStart types are:\n"));
+ printf(_(" auto start service automatically during system startup (default)\n"));
+ printf(_(" demand start service on demand\n"));
#endif
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
do_advice();
exit(1);
}
-
}
+#if defined(WIN32) || defined(__CYGWIN__)
+static void
+set_starttype(char *starttypeopt)
+{
+ if (strcmp(starttypeopt, "a") == 0 || strcmp(starttypeopt, "auto") == 0)
+ pgctl_start_type = SERVICE_AUTO_START;
+ else if (strcmp(starttypeopt, "d") == 0 || strcmp(starttypeopt, "demand") == 0)
+ pgctl_start_type = SERVICE_DEMAND_START;
+ else
+ {
+ write_stderr(_("%s: unrecognized start type \"%s\"\n"), progname, starttypeopt);
+ do_advice();
+ exit(1);
+ }
+}
+#endif
+
int
main(int argc, char **argv)
/* process command-line options */
while (optind < argc)
{
- while ((c = getopt_long(argc, argv, "cD:l:m:N:o:p:P:st:U:wW", long_options, &option_index)) != -1)
+ while ((c = getopt_long(argc, argv, "cD:l:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1)
{
switch (c)
{
case 's':
silent_mode = true;
break;
+ case 'S':
+#if defined(WIN32) || defined(__CYGWIN__)
+ set_starttype(optarg);
+#else
+ write_stderr(_("%s: -S option not supported on this platform\n"),
+ progname);
+ exit(1);
+#endif
+ break;
case 't':
wait_seconds = atoi(optarg);
break;
if (pg_data == NULL &&
ctl_command != KILL_COMMAND && ctl_command != UNREGISTER_COMMAND)
{
- write_stderr(_("%s: no database directory specified "
- "and environment variable PGDATA unset\n"),
+ write_stderr(_("%s: no database directory specified and environment variable PGDATA unset\n"),
progname);
do_advice();
exit(1);