[runit integration] give a bit of time to start the service
Currently, we run sv start immediately after linking the service. The runsv process may not be up at the moment, as a result of which openrc will mark the service as stopped, even though it may be brought up by runit at the next scan. This is documented in the gentoo wiki: https://wiki.gentoo.org/wiki/Runit#OpenRC.27s_runit_integration_feature This PR adds a timeout so that correct process state can be reported. Before: * Starting netdata-runit ... fail: /run/openrc/sv/netdata: runsv not running * Failed to start netdata-runit After: * Starting netdata-runit ... fail: /run/openrc/sv/netdata: runsv not running ok: run: /run/openrc/sv/netdata: (pid 9042) 0s This fixes #253.
This commit is contained in:
parent
d65e603acd
commit
6e24d33517
16
sh/runit.sh
16
sh/runit.sh
@ -20,8 +20,20 @@ runit_start()
|
|||||||
service_link="${RC_SVCDIR}/sv/${service_path##*/}"
|
service_link="${RC_SVCDIR}/sv/${service_path##*/}"
|
||||||
ebegin "Starting ${name:-$RC_SVCNAME}"
|
ebegin "Starting ${name:-$RC_SVCNAME}"
|
||||||
ln -snf "${service_path}" "${service_link}"
|
ln -snf "${service_path}" "${service_link}"
|
||||||
sv start "${service_link}" > /dev/null 2>&1
|
local i=0 retval=1
|
||||||
eend $? "Failed to start ${name:-$RC_SVCNAME}"
|
# it can take upto 5 seconds for runsv to start
|
||||||
|
while [ $i -lt 6 ] ; do
|
||||||
|
if sv start "${service_link}" > /dev/null 2>&1; then
|
||||||
|
retval=0
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1 && i=$(expr $i + 1)
|
||||||
|
done
|
||||||
|
if [ $retval -eq 1 ]; then
|
||||||
|
# clean up the link else sv will keep on trying
|
||||||
|
rm "${service_link}"
|
||||||
|
fi
|
||||||
|
eend $retval "Failed to start ${name:-$RC_SVCNAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
runit_stop()
|
runit_stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user