From 8b20b3689e221adef0ee2b2221cf17633ac8189c Mon Sep 17 00:00:00 2001 From: maguoliang Date: Mon, 6 Jan 2020 17:48:25 +0800 Subject: [PATCH 1/2] fix logrotate empty file hole issue refer to https://github.com/ossrs/srs/issues/1554 --- trunk/etc/logrotate.d/srs | 15 +++++++++++++++ trunk/src/app/srs_app_log.cpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 trunk/etc/logrotate.d/srs diff --git a/trunk/etc/logrotate.d/srs b/trunk/etc/logrotate.d/srs new file mode 100644 index 00000000000..19147a44031 --- /dev/null +++ b/trunk/etc/logrotate.d/srs @@ -0,0 +1,15 @@ +/data/log/srs/*.log { + +weekly + +size 200M + +copytruncate + +rotate 5 + +dateext + +noolddir + +} \ No newline at end of file diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp index 67f26930ba9..1c0a5dfd155 100644 --- a/trunk/src/app/srs_app_log.cpp +++ b/trunk/src/app/srs_app_log.cpp @@ -414,7 +414,7 @@ void SrsFastLog::open_log_file() if(fd == -1 && errno == ENOENT) { fd = open(filename.c_str(), - O_RDWR | O_CREAT | O_TRUNC, + O_RDWR | O_CREAT | O_TRUNC | O_APPEND/*logrotate copytruncate need this flag*/, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH ); } From 8a585805970f95615306cfb3d1319b6b384e8adf Mon Sep 17 00:00:00 2001 From: maguoliang Date: Tue, 7 Jan 2020 10:41:49 +0800 Subject: [PATCH 2/2] remove logrotate.d/srs /data/log/srs/*.log { weekly size 200M copytruncate rotate 5 dateext noolddir } --- trunk/etc/logrotate.d/srs | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 trunk/etc/logrotate.d/srs diff --git a/trunk/etc/logrotate.d/srs b/trunk/etc/logrotate.d/srs deleted file mode 100644 index 19147a44031..00000000000 --- a/trunk/etc/logrotate.d/srs +++ /dev/null @@ -1,15 +0,0 @@ -/data/log/srs/*.log { - -weekly - -size 200M - -copytruncate - -rotate 5 - -dateext - -noolddir - -} \ No newline at end of file