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
[-- Attachment #1 --]
Changing this to:
- - -
meteoavg_start() {
/usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} ${meteoavg_wfpuser} ${meteoavg_wfpdb} "/usr/local/bin/${name} ${meteoavg_flags}" &
}
- - -
does not solve the issue.
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>:
>
> 27.04.2022 21:30, Axel Rau wrote:
>> Hi all,
>>
>> I have this rc script:
>> - - -
>> meteoavg_wfphost="dbb3"
>> meteoavg_wfpuser="meteo"
>> meteoavg_wfpdb="operations"
>> #
>> #
>>
>> . /etc/rc.subr
>>
>> name="meteoavg"
>> rcvar=${name}_enable
>> command=/usr/local/bin/meteoavg
>>
>> load_rc_config $name
>>
>> : ${meteoavg_enable="NO"}
>> : ${meteoavg_flags=" -l syslog:daemon -s Chaos1"}
>>
>> : ${meteoavg_pidfile="/var/run/meteoavg-Chaos1.pid"}
>>
>> pidfile="${meteoavg_pidfile}"
>>
>> ##start_cmd="${name}_start"
>> stop_precmd="${name}_prestop"
>>
>> meteoavg_start() {
>> /usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} \
>> ${meteoavg_wfpuser} ${meteoavg_wfpdb} \
>> "/usr/local/bin/${name} ${meteoavg_flags} &"
>> }
>
>> - - -
>> The rc ignores the '&' and waits for wait_for_pgsql.sh to complete.
>>
>> How can I let rc continue without waiting?
>
> 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.
>
Axel
---
PGP-Key: CDE74120 ☀ computing @ chaos claudius
[-- Attachment #2 --]
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Changing this to:<div class="">- - -</div><div class=""><div class="">meteoavg_start() {</div><div class=""> /usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} ${meteoavg_wfpuser} ${meteoavg_wfpdb} "/usr/local/bin/${name} ${meteoavg_flags}" &</div><div class="">}</div><div class="">- - -</div><div class="">does not solve the issue. </div><div class="">On system boot this script still blocks rc and prevents any other services from being started,</div><div class="">including the the jail with the pgsql server, where wait_for_pgsql.sh tries to connect.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div><br class=""><blockquote type="cite" class=""><div class="">Am 27.04.2022 um 16:37 schrieb Eugene Grosbein <<a href="mailto:eugen@grosbein.net" class="">eugen@grosbein.net</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="">27.04.2022 21:30, Axel Rau wrote:<br class=""><blockquote type="cite" class="">Hi all,<br class=""><br class="">I have this rc script:<br class="">- - -<br class="">meteoavg_wfphost="dbb3"<br class="">meteoavg_wfpuser="meteo"<br class="">meteoavg_wfpdb="operations"<br class="">#<br class="">#<br class=""><br class="">. /etc/rc.subr<br class=""><br class="">name="meteoavg"<br class="">rcvar=${name}_enable<br class="">command=/usr/local/bin/meteoavg<br class=""><br class="">load_rc_config $name<br class=""><br class="">: ${meteoavg_enable="NO"}<br class="">: ${meteoavg_flags=" -l syslog:daemon -s Chaos1"}<br class=""><br class="">: ${meteoavg_pidfile="/var/run/meteoavg-Chaos1.pid"}<br class=""><br class="">pidfile="${meteoavg_pidfile}"<br class=""><br class="">##start_cmd="${name}_start"<br class="">stop_precmd="${name}_prestop"<br class=""><br class="">meteoavg_start() {<br class=""> /usr/local/bin/wait_for_pgsql.sh ${meteoavg_wfphost} \<br class=""> ${meteoavg_wfpuser} ${meteoavg_wfpdb} \<br class=""> "/usr/local/bin/${name} ${meteoavg_flags} &"<br class="">}<br class=""></blockquote><br class=""><blockquote type="cite" class="">- - -<br class="">The rc ignores the '&' and waits for wait_for_pgsql.sh to complete.<br class=""><br class="">How can I let rc continue without waiting?<br class=""></blockquote><br class="">You need to place '&' outside of double-quotes.<br class="">But better use daemon(8) command instead of '&'<br class="">because daemon does better job ignoring signals etc.<br class="">and that may be important if wait time extends past point when system goes to multiuser mode.<br class=""><br class=""></div></div></blockquote><br class=""></div><div>Axel</div><div class="">
<div dir="auto" style="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-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="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-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="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=""><div style="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=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant-ligatures: 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=""><div class="">---<br class="">PGP-Key: CDE74120 ☀ computing @ chaos claudius</div></div></div></div></div></div>
</div>
<br class=""></body></html>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?772ECD57-2322-4FF9-B5A4-D10D8795D32E>
