mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Remove silent_mode. You get the same functionality with "pg_ctl -l
postmaster.log", or nohup. There was a small issue with LINUX_OOM_ADJ and silent_mode, namely that with silent_mode the postmaster process incorrectly used the OOM settings meant for backend processes. We certainly could've fixed that directly, but since silent_mode was redundant anyway, we might as well just remove it.
This commit is contained in:
parent
f563afd433
commit
f7ea6beaf4
@ -3201,36 +3201,6 @@ local0.* /var/log/postgresql
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-silent-mode" xreflabel="silent_mode">
|
||||
<term><varname>silent_mode</varname> (<type>boolean</type>)</term>
|
||||
<indexterm>
|
||||
<primary><varname>silent_mode</> configuration parameter</primary>
|
||||
</indexterm>
|
||||
<listitem>
|
||||
<para>
|
||||
Runs the server silently. If this parameter is set, the server
|
||||
will automatically run in background and disassociate from the
|
||||
controlling terminal.
|
||||
This parameter can only be set at server start.
|
||||
</para>
|
||||
|
||||
<caution>
|
||||
<para>
|
||||
When this parameter is set,
|
||||
the server's standard output and standard error are redirected
|
||||
to the file <filename>postmaster.log</> within the data directory.
|
||||
There is no provision for rotating this file, so it will grow
|
||||
indefinitely unless server log output is redirected elsewhere
|
||||
by other settings. It is recommended that <varname>log_destination</>
|
||||
be set to <literal>syslog</> or that <varname>logging_collector</> be
|
||||
enabled when using this option. Even with those measures, errors
|
||||
reported early during startup may appear in
|
||||
<filename>postmaster.log</> rather than the normal log destination.
|
||||
</para>
|
||||
</caution>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</sect2>
|
||||
<sect2 id="runtime-config-logging-when">
|
||||
|
@ -58,8 +58,7 @@
|
||||
* Error Reporting:
|
||||
* Use write_stderr() only for reporting "interactive" errors
|
||||
* (essentially, bogus arguments on the command line). Once the
|
||||
* postmaster is launched, use ereport(). In particular, don't use
|
||||
* write_stderr() for anything that occurs after pmdaemonize.
|
||||
* postmaster is launched, use ereport().
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -192,7 +191,6 @@ static int SendStop = false;
|
||||
|
||||
/* still more option variables */
|
||||
bool EnableSSL = false;
|
||||
bool SilentMode = false; /* silent_mode */
|
||||
|
||||
int PreAuthDelay = 0;
|
||||
int AuthenticationTimeout = 60;
|
||||
@ -326,7 +324,6 @@ static DNSServiceRef bonjour_sdref = NULL;
|
||||
*/
|
||||
static void getInstallationPaths(const char *argv0);
|
||||
static void checkDataDir(void);
|
||||
static void pmdaemonize(void);
|
||||
static Port *ConnCreate(int serverFd);
|
||||
static void ConnFree(Port *port);
|
||||
static void reset_shared(int port);
|
||||
@ -777,15 +774,6 @@ PostmasterMain(int argc, char *argv[])
|
||||
(errmsg_internal("-----------------------------------------")));
|
||||
}
|
||||
|
||||
/*
|
||||
* Fork away from controlling terminal, if silent_mode specified.
|
||||
*
|
||||
* Must do this before we grab any interlock files, else the interlocks
|
||||
* will show the wrong PID.
|
||||
*/
|
||||
if (SilentMode)
|
||||
pmdaemonize();
|
||||
|
||||
/*
|
||||
* Create lockfile for data directory.
|
||||
*
|
||||
@ -1270,105 +1258,6 @@ checkDataDir(void)
|
||||
FreeFile(fp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Fork away from the controlling terminal (silent_mode option)
|
||||
*
|
||||
* Since this requires disconnecting from stdin/stdout/stderr (in case they're
|
||||
* linked to the terminal), we re-point stdin to /dev/null and stdout/stderr
|
||||
* to "postmaster.log" in the data directory, where we're already chdir'd.
|
||||
*/
|
||||
static void
|
||||
pmdaemonize(void)
|
||||
{
|
||||
#ifndef WIN32
|
||||
const char *pmlogname = "postmaster.log";
|
||||
int dvnull;
|
||||
int pmlog;
|
||||
pid_t pid;
|
||||
int res;
|
||||
|
||||
/*
|
||||
* Make sure we can open the files we're going to redirect to. If this
|
||||
* fails, we want to complain before disconnecting. Mention the full path
|
||||
* of the logfile in the error message, even though we address it by
|
||||
* relative path.
|
||||
*/
|
||||
dvnull = open(DEVNULL, O_RDONLY, 0);
|
||||
if (dvnull < 0)
|
||||
{
|
||||
write_stderr("%s: could not open file \"%s\": %s\n",
|
||||
progname, DEVNULL, strerror(errno));
|
||||
ExitPostmaster(1);
|
||||
}
|
||||
pmlog = open(pmlogname, O_CREAT | O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR);
|
||||
if (pmlog < 0)
|
||||
{
|
||||
write_stderr("%s: could not open log file \"%s/%s\": %s\n",
|
||||
progname, DataDir, pmlogname, strerror(errno));
|
||||
ExitPostmaster(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Okay to fork.
|
||||
*/
|
||||
pid = fork_process();
|
||||
if (pid == (pid_t) -1)
|
||||
{
|
||||
write_stderr("%s: could not fork background process: %s\n",
|
||||
progname, strerror(errno));
|
||||
ExitPostmaster(1);
|
||||
}
|
||||
else if (pid)
|
||||
{ /* parent */
|
||||
/* Parent should just exit, without doing any atexit cleanup */
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
MyProcPid = PostmasterPid = getpid(); /* reset PID vars to child */
|
||||
|
||||
MyStartTime = time(NULL);
|
||||
|
||||
/*
|
||||
* Some systems use setsid() to dissociate from the TTY's process group,
|
||||
* while on others it depends on stdin/stdout/stderr. Do both if
|
||||
* possible.
|
||||
*/
|
||||
#ifdef HAVE_SETSID
|
||||
if (setsid() < 0)
|
||||
{
|
||||
write_stderr("%s: could not dissociate from controlling TTY: %s\n",
|
||||
progname, strerror(errno));
|
||||
ExitPostmaster(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Reassociate stdin/stdout/stderr. fork_process() cleared any pending
|
||||
* output, so this should be safe. The only plausible error is EINTR,
|
||||
* which just means we should retry.
|
||||
*/
|
||||
do
|
||||
{
|
||||
res = dup2(dvnull, 0);
|
||||
} while (res < 0 && errno == EINTR);
|
||||
close(dvnull);
|
||||
do
|
||||
{
|
||||
res = dup2(pmlog, 1);
|
||||
} while (res < 0 && errno == EINTR);
|
||||
do
|
||||
{
|
||||
res = dup2(pmlog, 2);
|
||||
} while (res < 0 && errno == EINTR);
|
||||
close(pmlog);
|
||||
#else /* WIN32 */
|
||||
/* not supported */
|
||||
elog(FATAL, "silent_mode is not supported under Windows");
|
||||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main idle loop of postmaster
|
||||
*/
|
||||
|
@ -824,16 +824,6 @@ static struct config_bool ConfigureNamesBool[] =
|
||||
true,
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
{"silent_mode", PGC_POSTMASTER, LOGGING_WHERE,
|
||||
gettext_noop("Runs the server silently."),
|
||||
gettext_noop("If this parameter is set, the server will automatically run in the "
|
||||
"background and any controlling terminals are dissociated.")
|
||||
},
|
||||
&SilentMode,
|
||||
false,
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
{"log_checkpoints", PGC_SIGHUP, LOGGING_WHAT,
|
||||
gettext_noop("Logs each checkpoint."),
|
||||
|
@ -300,11 +300,6 @@
|
||||
#syslog_facility = 'LOCAL0'
|
||||
#syslog_ident = 'postgres'
|
||||
|
||||
#silent_mode = off # Run server silently.
|
||||
# DO NOT USE without syslog or
|
||||
# logging_collector
|
||||
# (change requires restart)
|
||||
|
||||
|
||||
# - When to Log -
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user