]> TLD Linux GIT Repositories - packages/munin.git/commitdiff
- fixed asyncd init script, added asyncd sysconfig
authorMarcin Krol <hawk@tld-linux.org>
Wed, 14 Oct 2015 09:30:26 +0000 (09:30 +0000)
committerMarcin Krol <hawk@tld-linux.org>
Wed, 14 Oct 2015 09:30:26 +0000 (09:30 +0000)
munin-asyncd.init
munin-asyncd.sysconfig [new file with mode: 0644]
munin.spec

index b7a89d161572e1c6c8d41a7a4bbe39b813e6888d..5340110fac186e1f558555f8d0422400a7e8d6aa 100755 (executable)
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
+# Get config
+. /etc/sysconfig/munin-asyncd
+
+# Set defaults in case they're not defined in config
+MUNIN_NODE_HOST=${MUNIN_NODE_HOST:-localhost}
+MUNIN_NODE_PORT=${MUNIN_NODE_HOST:-4949}
+MUNIN_ASYNCD_SHUTDOWN_TIMEOUT=${MUNIN_ASYNCD_SHUTDOWN_TIMEOUT:-15}
+
 start() {
        # Check if the service is already running?
        if [ -f /var/lock/subsys/munin-asyncd ]; then
 start() {
        # Check if the service is already running?
        if [ -f /var/lock/subsys/munin-asyncd ]; then
@@ -31,7 +39,7 @@ start() {
        fi
 
        msg_starting "munin-asyncd"
        fi
 
        msg_starting "munin-asyncd"
-       daemon /usr/sbin/munin-asyncd
+       daemon --fork /usr/sbin/munin-asyncd --host ${MUNIN_NODE_HOST}:${MUNIN_NODE_PORT}
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/munin-asyncd
 }
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/munin-asyncd
 }
@@ -43,7 +51,25 @@ stop() {
        fi
 
        msg_stopping "munin-asyncd"
        fi
 
        msg_stopping "munin-asyncd"
-       killproc munin-asyncd
+       busy
+       # We can't kill by process name, asyncd is changing it dynamically
+       # so we simply send TERM to all asyncd processes
+       for ppid in $(pgrep "^munin-asyncd "); do
+               kill -TERM ${ppid}
+       done
+       timeout=0
+       while pgrep "^munin-asyncd " 1>/dev/null 2>&1; do
+               # If timeout was reached send kill signal and break loop
+               if [ $timeout -ge $MUNIN_ASYNCD_SHUTDOWN_TIMEOUT ]; then
+                       for ppid in $(pgrep "^munin-asyncd "); do
+                               kill -KILL ${ppid}
+                       done
+                       break
+               fi
+               sleep 1
+               timeout=$((timeout+1))
+       done
+       ok
        rm -f /var/lock/subsys/munin-asyncd
 }
 
        rm -f /var/lock/subsys/munin-asyncd
 }
 
diff --git a/munin-asyncd.sysconfig b/munin-asyncd.sysconfig
new file mode 100644 (file)
index 0000000..dc7cb58
--- /dev/null
@@ -0,0 +1,8 @@
+# Munin node IP address or hostname (default is localhost)
+#MUNIN_NODE_HOST="localhost"
+
+# Munin node port (default is 4949)
+#MUNIN_NODE_PORT="4949"
+
+# maximum time (in seconds) to wait for munin-asyncd to stop
+MUNIN_ASYNCD_SHUTDOWN_TIMEOUT="15"
index 8fe90b5357a0225056bbf047450bcd0966bfce47..428636493a7742fb4b2a79d4c262c882e61148ed 100644 (file)
@@ -1,7 +1,3 @@
-# TODO
-# - R: perl* should be autogenerated?
-# - add plugins-java package and proper BRs
-#
 # Condtional build:
 %bcond_with    sybase          # add Sybase support to munin-node
 
 # Condtional build:
 %bcond_with    sybase          # add Sybase support to munin-node
 
@@ -23,6 +19,7 @@ Source5:      %{name}-node.logrotate
 Source6:       %{name}-lighttpd.conf
 Source8:       %{name}-httpd.conf
 Source11:      %{name}-asyncd.init
 Source6:       %{name}-lighttpd.conf
 Source8:       %{name}-httpd.conf
 Source11:      %{name}-asyncd.init
+Source12:      %{name}-asyncd.sysconfig
 Patch0:                %{name}-Makefile.patch
 Patch1:                %{name}-plugins.patch
 Patch2:                %{name}-templatedir.patch
 Patch0:                %{name}-Makefile.patch
 Patch1:                %{name}-plugins.patch
 Patch2:                %{name}-templatedir.patch
@@ -136,7 +133,7 @@ Munin.
 
 %install
 rm -rf $RPM_BUILD_ROOT
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{/etc/{rc.d/init.d,cron.d,logrotate.d},%{_bindir},%{_sbindir}} \
+install -d $RPM_BUILD_ROOT{/etc/{rc.d/init.d,cron.d,logrotate.d,sysconfig},%{_bindir},%{_sbindir}} \
        $RPM_BUILD_ROOT/var/log/archive/munin \
        $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
 
        $RPM_BUILD_ROOT/var/log/archive/munin \
        $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
 
@@ -148,8 +145,10 @@ install -d $RPM_BUILD_ROOT{/etc/{rc.d/init.d,cron.d,logrotate.d},%{_bindir},%{_s
 # move asyncd daemon do sbin
 %{__mv} $RPM_BUILD_ROOT{%{_datadir}/munin,%{_sbindir}}/munin-asyncd
 
 # move asyncd daemon do sbin
 %{__mv} $RPM_BUILD_ROOT{%{_datadir}/munin,%{_sbindir}}/munin-asyncd
 
-install -p %{SOURCE11} $RPM_BUILD_ROOT/etc/rc.d/init.d/munin-asyncd
 install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/munin-node
 install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/munin-node
+install -p %{SOURCE11} $RPM_BUILD_ROOT/etc/rc.d/init.d/munin-asyncd
+install %{SOURCE12} $RPM_BUILD_ROOT/etc/sysconfig/munin-asyncd
+
 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/cron.d/munin
 cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/logrotate.d/munin
 cp -p %{SOURCE5} $RPM_BUILD_ROOT/etc/logrotate.d/munin-node
 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/cron.d/munin
 cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/logrotate.d/munin
 cp -p %{SOURCE5} $RPM_BUILD_ROOT/etc/logrotate.d/munin-node
@@ -158,6 +157,7 @@ cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
 cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
 cp -p %{SOURCE6} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
 
 cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
 cp -p %{SOURCE6} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
 
+
 cp -p dists/tarball/plugins.conf $RPM_BUILD_ROOT%{_sysconfdir}
 ln -sf %{_sysconfdir}/plugins.conf $RPM_BUILD_ROOT%{_sysconfdir}/plugin-conf.d/munin-node
 
 cp -p dists/tarball/plugins.conf $RPM_BUILD_ROOT%{_sysconfdir}
 ln -sf %{_sysconfdir}/plugins.conf $RPM_BUILD_ROOT%{_sysconfdir}/plugin-conf.d/munin-node
 
@@ -311,6 +311,7 @@ fi
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/plugins.conf
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/plugin-conf.d/munin-node
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/munin-node
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/plugins.conf
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/plugin-conf.d/munin-node
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/munin-node
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/munin-asyncd
 %attr(754,root,root) /etc/rc.d/init.d/munin-asyncd
 %attr(754,root,root) /etc/rc.d/init.d/munin-node
 %attr(755,root,root) %{_bindir}/munindoc
 %attr(754,root,root) /etc/rc.d/init.d/munin-asyncd
 %attr(754,root,root) /etc/rc.d/init.d/munin-node
 %attr(755,root,root) %{_bindir}/munindoc
@@ -337,7 +338,3 @@ fi
 %{_mandir}/man3/Munin::Node*
 %{_mandir}/man3/Munin::Plugin*
 %{_mandir}/man5/munin-node.conf*
 %{_mandir}/man3/Munin::Node*
 %{_mandir}/man3/Munin::Plugin*
 %{_mandir}/man5/munin-node.conf*
-
-#%files plugins-java
-#%defattr(644,root,root,755)
-#%{_datadir}/munin/munin-jmx-plugins.jar