From a69bdbb56ca2355b4b99bc4673467657c318fb71 Mon Sep 17 00:00:00 2001 From: Alan Pevec Date: Sep 10 2014 21:47:14 +0000 Subject: actually install sysV service startup wrapper --- diff --git a/daemon_notify.sh b/daemon_notify.sh new file mode 100755 index 0000000..b105876 --- /dev/null +++ b/daemon_notify.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# +# start process in the background and wait for its readiness notification +# via systemd style NOTIFY_SOCKET +# +daemon_notify() { + exec=$1 + pidfile=$2 + startuplog=$3 + timeout=$4 + + # Requires: + # uuidgen (util-linux) + # sleep (coreutils) + export NOTIFY_SOCKET='@/org/rdoproject/systemd/notify/'$(uuidgen) + python -m glance.openstack.common.systemd $timeout & + pidnotify=$! + $exec &>$startuplog & + pid=$! + while [ -d /proc/$pid -a -d /proc/$pidnotify ] + do + sleep 1 + done + # pick up return codes from either process + if [ ! -d /proc/$pid ] + then + wait $pid + retval=$? + else + retval=-1 + fi + if [ ! -d /proc/$pidnotify ] + then + wait $pidnotify + retnotify=$? + else + retnotify=-1 + fi + if [ $retnotify -eq 0 ] + then + # readiness notification received, all OK + echo $pid > $pidfile + return 0 + else + # readiness not received + if [ $retval -eq -1 ] + then + # process exists in unknown state + return 1 + else + # startup failed + return $retval + fi + fi +} + +daemon_notify "$@" +exit $? diff --git a/openstack-glance-api.init b/openstack-glance-api.init index 00c8a51..d36c243 100644 --- a/openstack-glance-api.init +++ b/openstack-glance-api.init @@ -21,6 +21,9 @@ prog=openstack-glance-$suffix exec="/usr/bin/glance-$suffix" config="/etc/glance/glance-$suffix.conf" pidfile="/var/run/glance/glance-$suffix.pid" +startuplog="/var/log/glance/$prog-startup.log" +timeout=60 +wrapper="/usr/share/glance/daemon_notify.sh" [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog @@ -30,7 +33,7 @@ start() { [ -x $exec ] || exit 5 [ -f $config ] || exit 6 echo -n $"Starting $prog: " - daemon --user glance --pidfile $pidfile "$exec &>/dev/null & echo \$! > $pidfile" + daemon --user glance --pidfile $pidfile "$wrapper $exec $pidfile $startuplog $timeout" retval=$? echo [ $retval -eq 0 ] && touch $lockfile diff --git a/openstack-glance-registry.init b/openstack-glance-registry.init index 8a8850b..225b7a9 100644 --- a/openstack-glance-registry.init +++ b/openstack-glance-registry.init @@ -21,6 +21,9 @@ prog=openstack-glance-$suffix exec="/usr/bin/glance-$suffix" config="/etc/glance/glance-$suffix.conf" pidfile="/var/run/glance/glance-$suffix.pid" +startuplog="/var/log/glance/$prog-startup.log" +timeout=60 +wrapper="/usr/share/glance/daemon_notify.sh" [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog @@ -30,7 +33,7 @@ start() { [ -x $exec ] || exit 5 [ -f $config ] || exit 6 echo -n $"Starting $prog: " - daemon --user glance --pidfile $pidfile "$exec &>/dev/null & echo \$! > $pidfile" + daemon --user glance --pidfile $pidfile "$wrapper $exec $pidfile $startuplog $timeout" retval=$? echo [ $retval -eq 0 ] && touch $lockfile diff --git a/openstack-glance-scrubber.init b/openstack-glance-scrubber.init index dc432e9..7df06ab 100644 --- a/openstack-glance-scrubber.init +++ b/openstack-glance-scrubber.init @@ -21,6 +21,9 @@ prog=openstack-glance-$suffix exec="/usr/bin/glance-$suffix" user_config="/etc/glance/glance-$suffix.conf" pidfile="/var/run/glance/glance-$suffix.pid" +startuplog="/var/log/glance/$prog-startup.log" +timeout=60 +wrapper="/usr/share/glance/daemon_notify.sh" [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog @@ -30,7 +33,7 @@ start() { [ -x $exec ] || exit 5 [ -f $user_config ] || exit 7 echo -n $"Starting $prog: " - daemon --user glance --pidfile $pidfile "$exec --daemon &>/dev/null & echo \$! > $pidfile" + daemon --user glance --pidfile $pidfile "$wrapper $exec $pidfile $startuplog $timeout" retval=$? echo [ $retval -eq 0 ] && touch $lockfile diff --git a/openstack-glance.spec b/openstack-glance.spec index 68287da..3990856 100644 --- a/openstack-glance.spec +++ b/openstack-glance.spec @@ -1,6 +1,6 @@ Name: openstack-glance Version: 2014.1.2 -Release: 4%{?dist} +Release: 5%{?dist} Summary: OpenStack Image Service Group: Applications/System @@ -23,6 +23,7 @@ Source10: openstack-glance-registry.init Source1000: openstack-glance-registry.upstart Source11: openstack-glance-scrubber.init Source1100: openstack-glance-scrubber.upstart +Source9999: daemon_notify.sh # # patches_base=2014.1.2 @@ -227,6 +228,7 @@ install -p -D -m 640 etc/schema-image.json %{buildroot}%{_sysconfdir}/glance/sch %if 0%{?rhel} == 6 # Install service readiness wrapper +install -p -D -m 755 %{SOURCE9999} %{buildroot}%{_datadir}/glance/daemon_notify.sh install -p -D -m 755 %{SOURCE9} %{buildroot}%{_initrddir}/openstack-glance-api install -p -D -m 644 %{SOURCE900} %{buildroot}%{_datadir}/glance/openstack-glance-api.upstart @@ -349,6 +351,7 @@ fi %{_datadir}/glance/glance-registry-dist-paste.ini %if 0%{?rhel} == 6 +%attr(0755, root, root) %{_datadir}/glance/daemon_notify.sh %{_datadir}/glance/openstack-glance-api.upstart %{_datadir}/glance/openstack-glance-registry.upstart %{_datadir}/glance/openstack-glance-scrubber.upstart @@ -384,7 +387,10 @@ fi %doc doc/build/html %changelog -* Thu Sep 4 2014 builder - 2014.1.2-4 +* Wed Sep 10 2014 Alan Pevec - 2014.1.2-5 +- Install sysV service startup wrapper + +* Thu Sep 4 2014 Haïkel Guémar - 2014.1.2-4 - Clean up an unrequired BR - Fix sysV/Upstart services installation