Date: Wed, 27 Apr 2022 16:30:20 +0200 From: Axel Rau <Axel.Rau@Chaos1.DE> To: freebsd-hackers@freebsd.org Subject: rc script to let a service wait for db available Message-ID: <f6201772-d124-a08f-3623-25f1a6190faf@Chaos1.DE>
next in thread | raw e-mail | index | archive | help
Hi all,
I have this rc script:
- - -
meteoavg_wfphost=3D"dbb3"
meteoavg_wfpuser=3D"meteo"
meteoavg_wfpdb=3D"operations"
#
#
. /etc/rc.subr
name=3D"meteoavg"
rcvar=3D${name}_enable
command=3D/usr/local/bin/meteoavg
load_rc_config $name
: ${meteoavg_enable=3D"NO"}
: ${meteoavg_flags=3D" -l syslog:daemon -s Chaos1"}
: ${meteoavg_pidfile=3D"/var/run/meteoavg-Chaos1.pid"}
pidfile=3D"${meteoavg_pidfile}"
##start_cmd=3D"${name}_start"
stop_precmd=3D"${name}_prestop"
meteoavg_start() {
/usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} \
${meteoavg_wfpuser} ${meteoavg_wfpdb} \
"/usr/local/bin/${name} ${meteoavg_flags} &"
}
meteoavg_prestop() {
/bin/pkill wait_for_pgsql.sh || /usr/bin/true
}
- - -
wait_for_pgsql.sh :
- - -
#!/bin/sh
host=3D"$1"
user=3D"$2"
db=3D"$3"
start_cmd=3D"$4"
while ! /usr/local/bin/psql -h $host -U $user -d $db -c 'SELECT 1;'=20
>/dev/null 2>&1; do
sleep 5
done
$start_cmd
- - -
The rc ignores the '&' and waits for wait_for_pgsql.sh to complete.
How can I let rc continue without waiting?
Any help appreciated,
Axel
=2D-=20
PGP-Key: CDE74120 =E2=98=80 computing @ chaos claudius
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f6201772-d124-a08f-3623-25f1a6190faf>
