From nobody Sat May 21 11:58:27 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 111D81B35F7D for ; Sat, 21 May 2022 11:58:40 +0000 (UTC) (envelope-from Axel.Rau@Chaos1.DE) Received: from mailout5.lrau.net (mailout5.lrau.net [IPv6:2a05:bec0:26:5::73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mailout5.lrau.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L52DZ5c2yz3J8r for ; Sat, 21 May 2022 11:58:38 +0000 (UTC) (envelope-from Axel.Rau@Chaos1.DE) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=chaos1.de; s=email1; h=References:To:Cc:In-Reply-To:Date:Subject:Mime-Version: Content-Type:Message-Id:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CqydEIo9kcjUbw0rTTffo0U+ypagDetiWWb+VgMEmTs=; b=LSC4NhOZisBydCGG9619R7Am5z BSzOIhir5b74SA1bja5bK7oXvaRYeAlvZjSI0mpu0jpuDR2r7gTmPN56Viilp4iAYiKCVNrb5h6Lg Xk9roklOLu+DtPMsyCn1NrOm0eCtFCAHjC+7xBS7637uw1Y0ydMciIqQcGDrRXVBkZUUaY7o7Cct6 imYi17HrBJReY9pFehNHttvoPTwTBU5BYoIMLIYlckVTt0Z+ItGFYPKszA9sdce+9eW0aMG76NBH+ 5i2wlaFH/msK66+Dt9X0IeYujhjJT8Bgtyb44/darIFJmLwUyV43PUOnhWQToNmmVs8kONlD3oyFu HqK6lwJw==; Received: from [2a05:bec0:26:5::74] (helo=imap5.lrau.net) by mailout5.lrau.net with esmtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1nsNkb-0005DN-8x; Sat, 21 May 2022 11:58:29 +0000 Received: from Axel.Rau@Chaos1.DE by imap5.lrau.net (Archiveopteryx 3.2.0) with esmtpsa id 1653134308-64998-63502/7/2; Sat, 21 May 2022 11:58:28 +0000 From: Axel Rau Message-Id: <772ECD57-2322-4FF9-B5A4-D10D8795D32E@Chaos1.DE> Content-Type: multipart/alternative; boundary="Apple-Mail=_BE46956C-9762-4CE3-B0E1-8591837FAA66" List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 Subject: Re: rc script to let a service wait for db available Date: Sat, 21 May 2022 13:58:27 +0200 In-Reply-To: Cc: Eugene Grosbein To: freebsd-hackers@freebsd.org References: X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Rspamd-Queue-Id: 4L52DZ5c2yz3J8r X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=chaos1.de header.s=email1 header.b=LSC4NhOZ; dmarc=none; spf=none (mx1.freebsd.org: domain of Axel.Rau@Chaos1.DE has no SPF policy when checking 2a05:bec0:26:5::73) smtp.mailfrom=Axel.Rau@Chaos1.DE X-Spamd-Result: default: False [-1.48 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[chaos1.de:s=email1]; NEURAL_HAM_MEDIUM(-0.99)[-0.987]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; DMARC_NA(0.00)[chaos1.de]; NEURAL_SPAM_SHORT(0.41)[0.410]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[chaos1.de:+]; RCPT_COUNT_TWO(0.00)[2]; DWL_DNSWL_NONE(0.00)[chaos1.de:dkim]; MLMMJ_DEST(0.00)[freebsd-hackers]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:197071, ipnet:2a05:bec0::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[2a05:bec0:26:5::73:from] X-ThisMailContainsUnwantedMimeParts: N --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 : >=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 Changing this = to:
- - -
meteoavg_st= art() {
    /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,
incl= uding 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@grosb= ein.net>:

27.04.2022 21:30, Axel Rau wrote:
Hi all,

I have this rc script:
- - -
meteo= avg_wfphost=3D"dbb3"
meteoavg_wfpuser=3D"meteo"
meteoavg_wfpdb=3D"operations"
#
#<= br class=3D"">
. /etc/rc.subr

= name=3D"meteoavg"
rcvar=3D${name}_enable
comm= and=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-Chaos= 1.pid"}

pidfile=3D"${meteoavg_pidfile}"

##start_cmd=3D"${name}_start"
sto= p_precmd=3D"${name}_prestop"

meteoavg_start(= ) {
   /usr/local/bin/wait_for_pgsql.sh = ${meteoavg_wfphost} \
    ${meteoavg_w= fpuser} ${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  =E2=98=80 =  computing @ chaos claudius

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