]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
logrotate: copy/paste daemon list from *-all-starter.conf 1393/head
authorLoic Dachary <loic@dachary.org>
Thu, 6 Mar 2014 23:07:26 +0000 (00:07 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 6 Mar 2014 23:47:58 +0000 (00:47 +0100)
Each upstart/*-all-starter.conf use the same script to find the list of
daemons and their ids. Copy it over to the corresponding logrotate.conf
script instead of using a less reliable script based on initctl list
output.

If logrotate fails to run initctl reload on a daemon, it will keep
writing to the rotated log file, even after it is deleted and until it
fills the disk. By using the exact same shell snippet as the upstart
scripts used to start the daemon, all of them will be sent the HUP
signal and reopen the log file that was just rotated.

http://tracker.ceph.com/issues/7072 fixes #7072

Signed-off-by: Loic Dachary <loic@dachary.org>
src/logrotate.conf
src/rgw/logrotate.conf

index e49285a9f508c3727898a64d1e6aac5488d6521b..9181b56f063c597561e65a4286542cdc3e1caf55 100644 (file)
         fi
         # Possibly reload twice, but depending on ceph.conf the reload above may be a no-op
         if which initctl > /dev/null 2>&1 && [ -x `which initctl` ]; then
-            # upstart reload isn't very helpful here:
-            #   https://bugs.launchpad.net/upstart/+bug/1012938
-           initctl list \
-               | sed -n 's/^\(ceph-\(mon\|osd\|mds\)\+\)[ \t]\+(\([^ \/]\+\)\/\([^ \/]\+\))[ \t]\+start\/.*$/\1 cluster=\3 id=\4/p' \
-               | while read l; do
-               initctl reload -- $l 2>/dev/null || :
-           done
+            for daemon in osd mon mds ; do
+              find -L /var/lib/ceph/$daemon/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[A-Za-z0-9]+-[A-Za-z0-9._-]+' -printf '%P\n' \
+                | while read f; do
+                    if [ -e "/var/lib/ceph/$daemon/$f/done" ] && [ -e "/var/lib/ceph/$daemon/$f/upstart" ] && [ ! -e "/var/lib/ceph/$daemon/$f/sysvinit" ]; then
+                      cluster="${f%%-*}"
+                      id="${f#*-}"
+
+                      initctl reload ceph-$daemon cluster="$cluster" id="$id" 2>/dev/null || :
+                    fi
+                  done
+            done
         fi
     endscript
     missingok
index 7fb3391bbec2f625af2e720db517b96666be0d04..7c6f74e18882d2902b15ac43181cc728842af63d 100644 (file)
         fi
         # Possibly reload twice, but depending on ceph.conf the reload above may be a no-op
         if which initctl > /dev/null 2>&1 && [ -x `which initctl` ]; then
-            # upstart reload isn't very helpful here:
-            #   https://bugs.launchpad.net/upstart/+bug/1012938
-           initctl list \
-               | sed -n 's/^\(radosgw\+\)[ \t]\+(\([^ \/]\+\)\/\([^ \/]\+\))[ \t]\+start\/.*$/\1 cluster=\2 id=\3/p' \
-               | while read l; do
-               initctl reload -- $l 2>/dev/null || :
-           done
+          find -L /var/lib/ceph/radosgw/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[A-Za-z0-9]+-[A-Za-z0-9._-]+' -printf '%P\n' \
+          | while read f; do
+            if [ -e "/var/lib/ceph/radosgw/$f/done" ]; then
+                cluster="${f%%-*}"
+                id="${f#*-}"
+                initctl reload radosgw cluster="$cluster" id="$id" 2>/dev/null || :
+            fi
+          done
         fi
     endscript
     missingok