Hi,

This is a small hack I'm experimenting with to allow an unmodified
service to notify s6 when it is "really up". It does this by grepping
the service's output for a certain pattern, then writing the U event.

Is this a reasonable approach, or too hackish and silly?

I feel like there could be a better implementation, one that doesn't
leave a "cat >/dev/null" process hanging around forever.

########################################
$ cat ./service
#! /usr/bin/env bash

for i in {1..3}; do
  echo preparing
  s6-sleep -m 250
done

echo ready

for i in {1..3}; do
  echo working
  s6-sleep -m 250
done

########################################
$ cat ./notifywhenmatch
#! /usr/bin/env execlineb -S0

pipeline -r { $@ }
pipeline -r { tee /dev/stderr }
pipeline -r
{
  if { grep -q ready }
  if { s6-ftrig-notify ./event U }
  redirfd -w 1 /dev/null
  cat
}
fdmove 2 1
wait { }
exit

########################################
$ s6-mkfifodir ./event
$ (s6-ftrig-wait ./event U && echo -e "\nReally UP") & ./notifywhenmatch ./service
preparing
preparing
preparing
ready
working
U
Really UP
working
working

Thanks,
--
Patrick Mahoney <[email protected]>

Reply via email to