1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Open log file after async process is completely separated from the main process.

This prevents the main process from also logging to the file.

Suggested by Jens Wilke.
This commit is contained in:
David Steele 2017-09-20 08:08:36 -04:00
parent 266c9ddcc1
commit 4d6c56b4d7
2 changed files with 11 additions and 3 deletions

View File

@ -33,6 +33,14 @@
</release-feature-list> </release-feature-list>
<release-refactor-list> <release-refactor-list>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="wilke.jens"/>
</release-item-contributor-list>
<p>Open log file after async process is completely separated from the main process to prevent the main process from also logging to the file.</p>
</release-item>
<release-item> <release-item>
<p>Dynamically generate list of files for C library build.</p> <p>Dynamically generate list of files for C library build.</p>
</release-item> </release-item>

View File

@ -102,9 +102,6 @@ sub process
# uncoverable branch false - reacquire the lock since it was released by the client process above # uncoverable branch false - reacquire the lock since it was released by the client process above
if (lockAcquire(cfgCommandName(cfgCommandGet()), false)) if (lockAcquire(cfgCommandName(cfgCommandGet()), false))
{ {
# Open the log file
logFileSet(storageLocal(), cfgOption(CFGOPT_LOG_PATH) . '/' . cfgOption(CFGOPT_STANZA) . '-archive-async');
# uncoverable branch true - chdir to / # uncoverable branch true - chdir to /
chdir '/' chdir '/'
or confess &log(ERROR, "unable to chdir to /: $OS_ERROR", ERROR_PATH_MISSING); or confess &log(ERROR, "unable to chdir to /: $OS_ERROR", ERROR_PATH_MISSING);
@ -123,6 +120,9 @@ sub process
setsid() setsid()
or confess &log(ERROR, "unable to create new session group: $OS_ERROR", ERROR_ASSERT); or confess &log(ERROR, "unable to create new session group: $OS_ERROR", ERROR_ASSERT);
# Open the log file
logFileSet(storageLocal(), cfgOption(CFGOPT_LOG_PATH) . '/' . cfgOption(CFGOPT_STANZA) . '-archive-async');
# Start processing # Start processing
$self->processServer(); $self->processServer();
} }