summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2014-06-05 14:55:52 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2014-06-06 18:19:01 -0400
commit616461d294bd9f5054ca38b302b6fc5d70fde20c (patch)
tree671cd2efc28166c2a8cb9d6273954e5a38ea5255 /src/mongo/util
parentdae863af3f695fe98c16473ca07d79fb106121c0 (diff)
downloadmongo-616461d294bd9f5054ca38b302b6fc5d70fde20c.tar.gz
SERVER-4905: add flag to disable mongo's builtin log rotation
To support the standalone utility, we need to give administrators support for disabling Mongo's builtin log rotation.
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/log.cpp4
-rw-r--r--src/mongo/util/log.h10
-rw-r--r--src/mongo/util/signal_handlers.cpp2
3 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/util/log.cpp b/src/mongo/util/log.cpp
index ebf7556f109..bd0af52aac7 100644
--- a/src/mongo/util/log.cpp
+++ b/src/mongo/util/log.cpp
@@ -66,11 +66,11 @@ namespace mongo {
return Status::OK();
}
- bool rotateLogs() {
+ bool rotateLogs(bool renameFiles) {
using logger::RotatableFileManager;
RotatableFileManager* manager = logger::globalRotatableFileManager();
RotatableFileManager::FileNameStatusPairVector result(
- manager->rotateAll("." + terseCurrentTime(false)));
+ manager->rotateAll(renameFiles, "." + terseCurrentTime(false)));
for (RotatableFileManager::FileNameStatusPairVector::iterator it = result.begin();
it != result.end(); it++) {
warning() << "Rotating log file " << it->first << " failed: " << it->second.toString()
diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h
index b61913a0d32..ab221bd01da 100644
--- a/src/mongo/util/log.h
+++ b/src/mongo/util/log.h
@@ -93,8 +93,16 @@ namespace logger {
/**
* Rotates the log files. Returns true if all logs rotate successfully.
+ *
+ * renameFiles - true means we rename files, false means we expect the file to be renamed
+ * externally
+ *
+ * logrotate on *nix systems expects us not to rename the file, it is expected that the program
+ * simply open the file again with the same name.
+ * We expect logrotate to rename the existing file before we rotate, and so the next open
+ * we do should result in a file create.
*/
- bool rotateLogs();
+ bool rotateLogs(bool renameFiles);
/** output the error # and error message with prefix.
handy for use as parm in uassert/massert.
diff --git a/src/mongo/util/signal_handlers.cpp b/src/mongo/util/signal_handlers.cpp
index 8d15ef4e912..863e946f045 100644
--- a/src/mongo/util/signal_handlers.cpp
+++ b/src/mongo/util/signal_handlers.cpp
@@ -306,7 +306,7 @@ namespace {
switch (actualSignal) {
case SIGUSR1:
// log rotate signal
- fassert(16782, rotateLogs());
+ fassert(16782, rotateLogs(serverGlobalParams.logRenameOnRotate));
logProcessDetailsForLogRotate();
break;
case SIGQUIT: