Sujet : Re: Delaying Autostart
De : jornws200602 (at) *nospam* xs4all.nl (Oscar)
Groupes : comp.sys.raspberry-piDate : 03. Jun 2025, 20:56:40
Autres entêtes
Organisation : A butterfly in Tokio
Message-ID : <101nk1o$7uua$1@dont-email.me>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
101niml$7k6m$2@dont-email.me>,
Oscar <
jornws200602@xs4all.nl> wrote:
Yeah. And curl is not *that* expensive to run. Maybe even less expensive
than ping, as it does not have the setuid overhead. But who's counting
clock cycles anyway?
Following up on myself: Okay, ping loads a bit quicker as it's
executable is smaller and it loads less libraries, but it still
is a setuid binary.
I must admit I still don't understand why you thing the overhead of
calling curl is a waste. Both are external programs and we're in a wait
loop anyway. Why hurry in between to sleep calls?
In this case curl beats ping, as OP's question was related to a slow
staring Grafana server. Ping can't tell if Grafana is running. With curl
you can see if a string is in the output.
Say for examplje you're waiting for a specific dasboard to load, with
the title "Hootenmany". You could run this slightly modified version:
while ! timeout 1 curl -s ${URL} | grep -qs Hootenanny
do
echo -n .
sleep 1
done
This will loop until curl returns something with the string 'Hootenanny'
within 1 second and fail if there's no network, no dns, no route to the
Grafana server or while Grafana server is still starting up.
And *that's* what the OP asked.
-- [J|O|R] <- .signature.gz