Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 May 2022 13:58:27 +0200
From:      Axel Rau <Axel.Rau@chaos1.de>
To:        freebsd-hackers@freebsd.org
Cc:        Eugene Grosbein <eugen@grosbein.net>
Subject:   Re: rc script to let a service wait for db available
Message-ID:  <772ECD57-2322-4FF9-B5A4-D10D8795D32E@Chaos1.DE>
In-Reply-To: <c17abf27-0997-5627-b9c8-98a76d8946a3@grosbein.net>
References:  <f6201772-d124-a08f-3623-25f1a6190faf@Chaos1.DE> <c17abf27-0997-5627-b9c8-98a76d8946a3@grosbein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_BE46956C-9762-4CE3-B0E1-8591837FAA66
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Changing this to:
- - -
meteoavg_start() {
    /usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} ${meteoavg_wfpus=
er} ${meteoavg_wfpdb} "/usr/local/bin/${name} ${meteoavg_flags}" &
}
- - -
does not solve the issue.=20
On system boot this script still blocks rc and prevents any other =
services from being started,
including the the jail with the pgsql server, where wait_for_pgsql.sh =
tries to connect.





> Am 27.04.2022 um 16:37 schrieb Eugene Grosbein <eugen@grosbein.net>:
>=20
> 27.04.2022 21:30, Axel Rau wrote:
>> Hi all,
>>=20
>> I have this rc script:
>> - - -
>> meteoavg_wfphost=3D"dbb3"
>> meteoavg_wfpuser=3D"meteo"
>> meteoavg_wfpdb=3D"operations"
>> #
>> #
>>=20
>> . /etc/rc.subr
>>=20
>> name=3D"meteoavg"
>> rcvar=3D${name}_enable
>> command=3D/usr/local/bin/meteoavg
>>=20
>> load_rc_config $name
>>=20
>> : ${meteoavg_enable=3D"NO"}
>> : ${meteoavg_flags=3D" -l syslog:daemon -s Chaos1"}
>>=20
>> : ${meteoavg_pidfile=3D"/var/run/meteoavg-Chaos1.pid"}
>>=20
>> pidfile=3D"${meteoavg_pidfile}"
>>=20
>> ##start_cmd=3D"${name}_start"
>> stop_precmd=3D"${name}_prestop"
>>=20
>> meteoavg_start() {
>>    /usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} \
>>     ${meteoavg_wfpuser} ${meteoavg_wfpdb} \
>>    "/usr/local/bin/${name} ${meteoavg_flags} &"
>> }
>=20
>> - - -
>> The rc ignores the '&' and waits for wait_for_pgsql.sh to complete.
>>=20
>> How can I let rc continue without waiting?
>=20
> You need to place '&' outside of double-quotes.
> But better use daemon(8) command instead of '&'
> because daemon does better job ignoring signals etc.
> and that may be important if wait time extends past point when system =
goes to multiuser mode.
>=20

Axel
=2D--
PGP-Key: CDE74120  =E2=98=80  computing @ chaos claudius


--Apple-Mail=_BE46956C-9762-4CE3-B0E1-8591837FAA66
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbs=
p-mode: space; line-break: after-white-space;" class=3D"">Changing this =
to:<div class=3D"">- - -</div><div class=3D""><div class=3D"">meteoavg_st=
art() {</div><div class=3D"">&nbsp; &nbsp; /usr/local/bin/wait_for_pgsql.=
sh ${meteoavg_wfphost} ${meteoavg_wfpuser} ${meteoavg_wfpdb} "/usr/local/=
bin/${name} ${meteoavg_flags}" &amp;</div><div class=3D"">}</div><div =
class=3D"">- - -</div><div class=3D"">does not solve the issue.&nbsp;</di=
v><div class=3D"">On system boot this script still blocks rc and =
prevents any other services from being started,</div><div class=3D"">incl=
uding the the jail with the pgsql server, where wait_for_pgsql.sh tries =
to connect.</div><div class=3D""><br class=3D""></div><div class=3D""><br=
 class=3D""></div><div class=3D""><br class=3D""></div><div class=3D""><b=
r class=3D""></div></div><div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D"">Am 27.04.2022 um 16:37 schrieb Eugene =
Grosbein &lt;<a href=3D"mailto:eugen@grosbein.net" class=3D"">eugen@grosb=
ein.net</a>&gt;:</div><br class=3D"Apple-interchange-newline"><div =
class=3D""><div class=3D"">27.04.2022 21:30, Axel Rau wrote:<br class=3D"=
"><blockquote type=3D"cite" class=3D"">Hi all,<br class=3D""><br =
class=3D"">I have this rc script:<br class=3D"">- - -<br class=3D"">meteo=
avg_wfphost=3D"dbb3"<br class=3D"">meteoavg_wfpuser=3D"meteo"<br =
class=3D"">meteoavg_wfpdb=3D"operations"<br class=3D"">#<br class=3D"">#<=
br class=3D""><br class=3D"">. /etc/rc.subr<br class=3D""><br class=3D"">=
name=3D"meteoavg"<br class=3D"">rcvar=3D${name}_enable<br class=3D"">comm=
and=3D/usr/local/bin/meteoavg<br class=3D""><br class=3D"">load_rc_config=
 $name<br class=3D""><br class=3D"">: ${meteoavg_enable=3D"NO"}<br =
class=3D"">: ${meteoavg_flags=3D" -l syslog:daemon -s Chaos1"}<br =
class=3D""><br class=3D"">: ${meteoavg_pidfile=3D"/var/run/meteoavg-Chaos=
1.pid"}<br class=3D""><br class=3D"">pidfile=3D"${meteoavg_pidfile}"<br =
class=3D""><br class=3D"">##start_cmd=3D"${name}_start"<br class=3D"">sto=
p_precmd=3D"${name}_prestop"<br class=3D""><br class=3D"">meteoavg_start(=
) {<br class=3D""> &nbsp;&nbsp;&nbsp;/usr/local/bin/wait_for_pgsql.sh =
${meteoavg_wfphost} \<br class=3D""> &nbsp;&nbsp;&nbsp;&nbsp;${meteoavg_w=
fpuser} ${meteoavg_wfpdb} \<br class=3D""> &nbsp;&nbsp;&nbsp;"/usr/local/=
bin/${name} ${meteoavg_flags} &amp;"<br class=3D"">}<br class=3D""></bloc=
kquote><br class=3D""><blockquote type=3D"cite" class=3D"">- - -<br =
class=3D"">The rc ignores the '&amp;' and waits for wait_for_pgsql.sh to =
complete.<br class=3D""><br class=3D"">How can I let rc continue without =
waiting?<br class=3D""></blockquote><br class=3D"">You need to place =
'&amp;' outside of double-quotes.<br class=3D"">But better use daemon(8) =
command instead of '&amp;'<br class=3D"">because daemon does better job =
ignoring signals etc.<br class=3D"">and that may be important if wait =
time extends past point when system goes to multiuser mode.<br class=3D""=
><br class=3D""></div></div></blockquote><br class=3D""></div><div>Axel</=
div><div class=3D"">
<div dir=3D"auto" style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, =
0); letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; text-decoration: none; word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><div=
 dir=3D"auto" style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); =
letter-spacing: normal; text-align: start; text-indent: 0px; text-transfo=
rm: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-wid=
th: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode:=
 space; line-break: after-white-space;" class=3D""><div style=3D"color: =
rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode:=
 space; line-break: after-white-space;" class=3D""><div style=3D"color: =
rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode:=
 space; line-break: after-white-space;" class=3D""><div style=3D"color: =
rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant-li=
gatures: normal; font-variant-position: normal; font-variant-caps: =
normal; font-variant-numeric: normal; font-variant-alternates: normal; =
font-variant-east-asian: normal; font-weight: normal; letter-spacing: =
normal; line-height: normal; orphans: 2; text-align: -webkit-auto; =
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word;=
 -webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><di=
v class=3D"">---<br class=3D"">PGP-Key:&nbsp;CDE74120 &nbsp;=E2=98=80 =
&nbsp;computing @ chaos claudius</div></div></div></div></div></div>
</div>
<br class=3D""></body></html>

--Apple-Mail=_BE46956C-9762-4CE3-B0E1-8591837FAA66--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?772ECD57-2322-4FF9-B5A4-D10D8795D32E>