]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart.sh: write logrotate conf to build dir
authorRishabh Dave <ridave@redhat.com>
Tue, 25 Aug 2020 07:28:12 +0000 (12:58 +0530)
committerRishabh Dave <ridave@redhat.com>
Tue, 29 Sep 2020 09:21:39 +0000 (14:51 +0530)
This should allow vstart_runner.py to rotate logs and also should allow
vstart cluster users to rotate logs manually.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/vstart.sh

index 1e7b84917356d41b17d13c6dba02af231055e470..b054da99547180f47c6ecf82e2577b836ff93869 100755 (executable)
@@ -719,6 +719,40 @@ $extra_conf
 EOF
 }
 
+write_logrotate_conf() {
+    out_dir=$(pwd)"/out/*.log"
+
+    cat << EOF
+$out_dir
+{
+    rotate 5
+    size 1G
+    copytruncate
+    compress
+    notifempty
+    missingok
+    sharedscripts
+    postrotate
+        # NOTE: assuring that the absence of one of the following processes
+        # won't abort the logrotate command.
+        killall -u $USER -q -1 ceph-mon ceph-mgr ceph-mds ceph-osd ceph-fuse radosgw rbd-mirror || echo ""
+    endscript
+}
+EOF
+}
+
+init_logrotate() {
+    logrotate_conf_path=$(pwd)"/logrotate.conf"
+    logrotate_state_path=$(pwd)"/logrotate.state"
+
+    if ! test -a $logrotate_conf_path; then
+        if test -a $logrotate_state_path; then
+            rm -f $logrotate_state_path
+        fi
+        write_logrotate_conf > $logrotate_conf_path
+    fi
+}
+
 start_mon() {
     local MONS=""
     local count=0
@@ -1557,3 +1591,5 @@ if [ -f "$STRAY_CONF_PATH" -a -n "$conf_fn" -a ! "$conf_fn" -ef "$STRAY_CONF_PAT
     echo "NOTE:"
     echo "    Remember to restart cluster after removing $STRAY_CONF_PATH"
 fi
+
+init_logrotate