summaryrefslogtreecommitdiffstats
path: root/snap-src
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-08-22 19:22:27 +0300
committerLauri Ojansivu <x@xet7.org>2019-08-22 19:22:27 +0300
commitcc792ddd57691bb54972c73b9c861c768fce8c34 (patch)
tree20770419a9beced67163f669813351b4e9a49f54 /snap-src
parentb8d60f0069a23b44c5de34379fddf5d7bc0f292b (diff)
downloadwekan-cc792ddd57691bb54972c73b9c861c768fce8c34.tar.gz
wekan-cc792ddd57691bb54972c73b9c861c768fce8c34.tar.bz2
wekan-cc792ddd57691bb54972c73b9c861c768fce8c34.zip
Snap: Delete old MongoDB log, and log to syslog instead, because
syslog usually already has log rotation. Thanks to xet7 ! Closes wekan/wekan-snap#92, closes #1911
Diffstat (limited to 'snap-src')
-rwxr-xr-xsnap-src/bin/mongodb-control28
1 files changed, 26 insertions, 2 deletions
diff --git a/snap-src/bin/mongodb-control b/snap-src/bin/mongodb-control
index 28e58670..db01cffd 100755
--- a/snap-src/bin/mongodb-control
+++ b/snap-src/bin/mongodb-control
@@ -16,6 +16,24 @@ fi
export LC_ALL=C
+# When starting MongoDB, if logfile exist, delete it, because now uses syslog instead of logfile,
+# because syslog usually already has log rotation.
+# https://github.com/wekan/wekan-snap/issues/92
+if test -f "$SNAP_COMMON/mongodb.log"; then
+ rm -f "$SNAP_COMMON/mongodb.log"
+fi
+
+# Alternative: When starting MongoDB, and using logfile, truncate log to last 1000 lines of text.
+# 1) If file exists:
+#if test -f "$SNAP_COMMON/mongodb.log"; then
+# # 2) Copy last 1000 lines to variable loglast1000lines.
+# loglast1000lines=$(tail -1000 "$SNAP_COMMON/mongodb.log")
+# # 3) Copy variable to replace original MongoDB log.
+# echo "$loglast1000lines" > "$SNAP_COMMON/mongodb.log"
+# # 4) Set variable to be empty.
+# loglast1000lines=""
+#fi
+
if [ -z "$MONGO_URL" ]; then
# start mongo deamon
@@ -31,11 +49,17 @@ if [ -z "$MONGO_URL" ]; then
fi
echo "mongodb bind options: $BIND_OPTIONS"
- mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $BIND_OPTIONS --smallfiles
+ ## OLD: Logging to file.
+ #mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $BIND_OPTIONS --smallfiles
+ ## NEW: Logging to syslog, that usually has already log rotation.
+ mongod --dbpath $SNAP_COMMON --syslog --journal $BIND_OPTIONS --smallfiles
else
- mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $MONGO_URL --smallfiles
+ ## OLD: Logging to file.
+ #mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $MONGO_URL --smallfiles
+ ## NEW: Logging to syslog, that usually has already log rotation.
+ mongod --dbpath $SNAP_COMMON --syslog --journal $MONGO_URL --smallfiles
fi