Skip to content

Commit f7ea6be

Browse files
committed
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.
1 parent f563afd commit f7ea6be

File tree

4 files changed

+1
-157
lines changed

4 files changed

+1
-157
lines changed

doc/src/sgml/config.sgml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,36 +3201,6 @@ local0.* /var/log/postgresql
32013201
</listitem>
32023202
</varlistentry>
32033203

3204-
<varlistentry id="guc-silent-mode" xreflabel="silent_mode">
3205-
<term><varname>silent_mode</varname> (<type>boolean</type>)</term>
3206-
<indexterm>
3207-
<primary><varname>silent_mode</> configuration parameter</primary>
3208-
</indexterm>
3209-
<listitem>
3210-
<para>
3211-
Runs the server silently. If this parameter is set, the server
3212-
will automatically run in background and disassociate from the
3213-
controlling terminal.
3214-
This parameter can only be set at server start.
3215-
</para>
3216-
3217-
<caution>
3218-
<para>
3219-
When this parameter is set,
3220-
the server's standard output and standard error are redirected
3221-
to the file <filename>postmaster.log</> within the data directory.
3222-
There is no provision for rotating this file, so it will grow
3223-
indefinitely unless server log output is redirected elsewhere
3224-
by other settings. It is recommended that <varname>log_destination</>
3225-
be set to <literal>syslog</> or that <varname>logging_collector</> be
3226-
enabled when using this option. Even with those measures, errors
3227-
reported early during startup may appear in
3228-
<filename>postmaster.log</> rather than the normal log destination.
3229-
</para>
3230-
</caution>
3231-
</listitem>
3232-
</varlistentry>
3233-
32343204
</variablelist>
32353205
</sect2>
32363206
<sect2 id="runtime-config-logging-when">

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
* Error Reporting:
5959
* Use write_stderr() only for reporting "interactive" errors
6060
* (essentially, bogus arguments on the command line). Once the
61-
* postmaster is launched, use ereport(). In particular, don't use
62-
* write_stderr() for anything that occurs after pmdaemonize.
61+
* postmaster is launched, use ereport().
6362
*
6463
*-------------------------------------------------------------------------
6564
*/
@@ -192,7 +191,6 @@ static int SendStop = false;
192191

193192
/* still more option variables */
194193
bool EnableSSL = false;
195-
bool SilentMode = false; /* silent_mode */
196194

197195
int PreAuthDelay = 0;
198196
int AuthenticationTimeout = 60;
@@ -326,7 +324,6 @@ static DNSServiceRef bonjour_sdref = NULL;
326324
*/
327325
static void getInstallationPaths(const char *argv0);
328326
static void checkDataDir(void);
329-
static void pmdaemonize(void);
330327
static Port *ConnCreate(int serverFd);
331328
static void ConnFree(Port *port);
332329
static void reset_shared(int port);
@@ -777,15 +774,6 @@ PostmasterMain(int argc, char *argv[])
777774
(errmsg_internal("-----------------------------------------")));
778775
}
779776

780-
/*
781-
* Fork away from controlling terminal, if silent_mode specified.
782-
*
783-
* Must do this before we grab any interlock files, else the interlocks
784-
* will show the wrong PID.
785-
*/
786-
if (SilentMode)
787-
pmdaemonize();
788-
789777
/*
790778
* Create lockfile for data directory.
791779
*
@@ -1270,105 +1258,6 @@ checkDataDir(void)
12701258
FreeFile(fp);
12711259
}
12721260

1273-
1274-
/*
1275-
* Fork away from the controlling terminal (silent_mode option)
1276-
*
1277-
* Since this requires disconnecting from stdin/stdout/stderr (in case they're
1278-
* linked to the terminal), we re-point stdin to /dev/null and stdout/stderr
1279-
* to "postmaster.log" in the data directory, where we're already chdir'd.
1280-
*/
1281-
static void
1282-
pmdaemonize(void)
1283-
{
1284-
#ifndef WIN32
1285-
const char *pmlogname = "postmaster.log";
1286-
int dvnull;
1287-
int pmlog;
1288-
pid_t pid;
1289-
int res;
1290-
1291-
/*
1292-
* Make sure we can open the files we're going to redirect to. If this
1293-
* fails, we want to complain before disconnecting. Mention the full path
1294-
* of the logfile in the error message, even though we address it by
1295-
* relative path.
1296-
*/
1297-
dvnull = open(DEVNULL, O_RDONLY, 0);
1298-
if (dvnull < 0)
1299-
{
1300-
write_stderr("%s: could not open file \"%s\": %s\n",
1301-
progname, DEVNULL, strerror(errno));
1302-
ExitPostmaster(1);
1303-
}
1304-
pmlog = open(pmlogname, O_CREAT | O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR);
1305-
if (pmlog < 0)
1306-
{
1307-
write_stderr("%s: could not open log file \"%s/%s\": %s\n",
1308-
progname, DataDir, pmlogname, strerror(errno));
1309-
ExitPostmaster(1);
1310-
}
1311-
1312-
/*
1313-
* Okay to fork.
1314-
*/
1315-
pid = fork_process();
1316-
if (pid == (pid_t) -1)
1317-
{
1318-
write_stderr("%s: could not fork background process: %s\n",
1319-
progname, strerror(errno));
1320-
ExitPostmaster(1);
1321-
}
1322-
else if (pid)
1323-
{ /* parent */
1324-
/* Parent should just exit, without doing any atexit cleanup */
1325-
_exit(0);
1326-
}
1327-
1328-
MyProcPid = PostmasterPid = getpid(); /* reset PID vars to child */
1329-
1330-
MyStartTime = time(NULL);
1331-
1332-
/*
1333-
* Some systems use setsid() to dissociate from the TTY's process group,
1334-
* while on others it depends on stdin/stdout/stderr. Do both if
1335-
* possible.
1336-
*/
1337-
#ifdef HAVE_SETSID
1338-
if (setsid() < 0)
1339-
{
1340-
write_stderr("%s: could not dissociate from controlling TTY: %s\n",
1341-
progname, strerror(errno));
1342-
ExitPostmaster(1);
1343-
}
1344-
#endif
1345-
1346-
/*
1347-
* Reassociate stdin/stdout/stderr. fork_process() cleared any pending
1348-
* output, so this should be safe. The only plausible error is EINTR,
1349-
* which just means we should retry.
1350-
*/
1351-
do
1352-
{
1353-
res = dup2(dvnull, 0);
1354-
} while (res < 0 && errno == EINTR);
1355-
close(dvnull);
1356-
do
1357-
{
1358-
res = dup2(pmlog, 1);
1359-
} while (res < 0 && errno == EINTR);
1360-
do
1361-
{
1362-
res = dup2(pmlog, 2);
1363-
} while (res < 0 && errno == EINTR);
1364-
close(pmlog);
1365-
#else /* WIN32 */
1366-
/* not supported */
1367-
elog(FATAL, "silent_mode is not supported under Windows");
1368-
#endif /* WIN32 */
1369-
}
1370-
1371-
13721261
/*
13731262
* Main idle loop of postmaster
13741263
*/

src/backend/utils/misc/guc.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -824,16 +824,6 @@ static struct config_bool ConfigureNamesBool[] =
824824
true,
825825
NULL, NULL, NULL
826826
},
827-
{
828-
{"silent_mode", PGC_POSTMASTER, LOGGING_WHERE,
829-
gettext_noop("Runs the server silently."),
830-
gettext_noop("If this parameter is set, the server will automatically run in the "
831-
"background and any controlling terminals are dissociated.")
832-
},
833-
&SilentMode,
834-
false,
835-
NULL, NULL, NULL
836-
},
837827
{
838828
{"log_checkpoints", PGC_SIGHUP, LOGGING_WHAT,
839829
gettext_noop("Logs each checkpoint."),

src/backend/utils/misc/postgresql.conf.sample

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,6 @@
300300
#syslog_facility = 'LOCAL0'
301301
#syslog_ident = 'postgres'
302302

303-
#silent_mode = off # Run server silently.
304-
# DO NOT USE without syslog or
305-
# logging_collector
306-
# (change requires restart)
307-
308303

309304
# - When to Log -
310305

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy