Date: Tue, 18 Nov 2008 12:01:05 +0000 From: RW <fbsd06@mlists.homeunix.com> To: freebsd-questions@freebsd.org Subject: Re: Delay startup of services in rc.conf || elswhere Message-ID: <20081118120105.4776f731@gumby.homeunix.com> In-Reply-To: <1E519418-C8C4-4DD5-BFDC-F95158DA097E@todoo.biz> References: <1E519418-C8C4-4DD5-BFDC-F95158DA097E@todoo.biz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 18 Nov 2008 12:05:33 +0100
bsd <bsd@todoo.biz> wrote:
> Hello,
>
>
> I have a server configured to start 10 services at startup (in /etc/
> rc.conf)
>
> Unfortunately, the startup of MySQL seems to be returning "ok"
> before It actually has started completely the program___ the next
> program rely on MySQL and does not start well because the database is
> not "fully" started.
>
> I would like to introduce something like a "sleep 10" timer in the
> service startup process___
The cleanest solution is to create a minimal rc script that will sort
between the mysql and the affected services, and just give it a start
command that pauses for 10 seconds.
I do a similar thing where I poll for network access before allowing
anything that relies on it to start.
#!/bin/sh
#
# PROVIDE: networkwait
# REQUIRE: named
# BEFORE: ntpdate
. /etc/rc.subr
networkwait_enable=${networkwait_enable:-"NO"}
name="networkwait"
rcvar=`set_rcvar`
stop_cmd=":"
start_cmd="networkwait_start"
networkwait_start(){
if [ "$networkwait_ping_hosts" ] ; then
host_list="${networkwait_ping_hosts}"
else
# No hosts supplied - use external nameservers
host_list=`awk '/^ *nameserver/ {print $2}
'< /etc/resolv.conf | grep -E -v '^127\.0+\.0+\.0*1'`
fi
echo -n "Waiting for network access ... "
while true ; do
for inet_host in $host_list ; do
if ping -nc1 $inet_host 2>&1 > /dev/null ; then
echo "ping to ${inet_host} succeeded."
# Re-Sync ipfilter and pf in case
# they had failed DNS lookups
/etc/rc.d/ipfilter resync
/etc/rc.d/pf resync
exit 0
fi
done
sleep 5
done
}
load_rc_config ${name}
run_rc_command "$1"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081118120105.4776f731>
