mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Implement "pg_ctl logrotate" command
Currently there are two ways to trigger log rotation in logging collector process: call pg_rotate_logfile() SQL-function or send SIGUSR1 signal directly to logging collector process. However, it's nice to have more suitable way for external tools to do that, which wouldn't require SQL connection or knowledge of logging collector pid. This commit implements triggering log rotation by "pg_ctl logrotate" command. Discussion: https://postgr.es/m/20180416.115435.28153375.horiguchi.kyotaro%40lab.ntt.co.jp Author: Kyotaro Horiguchi, Alexander Kuzmenkov, Alexander Korotkov
This commit is contained in:
@@ -1268,6 +1268,9 @@ PostmasterMain(int argc, char *argv[])
|
||||
*/
|
||||
RemovePromoteSignalFiles();
|
||||
|
||||
/* Do the same for logrotate signal file */
|
||||
RemoveLogrotateSignalFiles();
|
||||
|
||||
/* Remove any outdated file holding the current log filenames. */
|
||||
if (unlink(LOG_METAINFO_DATAFILE) < 0 && errno != ENOENT)
|
||||
ereport(LOG,
|
||||
@@ -5100,11 +5103,18 @@ sigusr1_handler(SIGNAL_ARGS)
|
||||
signal_child(PgArchPID, SIGUSR1);
|
||||
}
|
||||
|
||||
if (CheckPostmasterSignal(PMSIGNAL_ROTATE_LOGFILE) &&
|
||||
SysLoggerPID != 0)
|
||||
/* Tell syslogger to rotate logfile if requested */
|
||||
if (SysLoggerPID != 0)
|
||||
{
|
||||
/* Tell syslogger to rotate logfile */
|
||||
signal_child(SysLoggerPID, SIGUSR1);
|
||||
if (CheckLogrotateSignal())
|
||||
{
|
||||
signal_child(SysLoggerPID, SIGUSR1);
|
||||
RemoveLogrotateSignalFiles();
|
||||
}
|
||||
else if (CheckPostmasterSignal(PMSIGNAL_ROTATE_LOGFILE))
|
||||
{
|
||||
signal_child(SysLoggerPID, SIGUSR1);
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER) &&
|
||||
|
||||
Reference in New Issue
Block a user