URI: 
       move per-channel daemon to its own script - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit 0b40cdabd01e90ea614605fc00819fefa30b1a76
   DIR parent aea4bdf3acd506f2486022fac38f2cd7ea3d1c86
  HTML Author: Josuah Demangeon <mail@josuah.net>
       Date:   Mon,  8 Mar 2021 00:56:10 +0100
       
       move per-channel daemon to its own script
       
       This permits to add a check for only running channel serivces once per channel,
       using pgrep of the script name along with its arguments.
       
       The script kills its matching entr at exit or interruption to make sure that no
       stale entr live in the background while the channel service stopped.
       
       Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
       
       Diffstat:
         A annna-channel-service               |      29 +++++++++++++++++++++++++++++
         M annna-start-services                |      22 ++--------------------
       
       2 files changed, 31 insertions(+), 20 deletions(-)
       ---
   DIR diff --git a/annna-channel-service b/annna-channel-service
       @@ -0,0 +1,29 @@
       +#!/bin/sh
       +#
       +# Per-channel daemon that monitors incoming messages from ii out script.
       +#
       +
       +pgrep -f "$0 $*" | grep -vxq "$$" && exec echo "$0 $* already running"
       +trap 'exec pkill -U annna -f "entr .* ${PWD}/out"' INT TERM EXIT HUP
       +
       +server="$1"
       +channel="$2"
       +
       +iiroot="/home/annna/irc"
       +iibase="/home/annna/irc/${server}"
       +
       +ls "${iibase}/${channel}/out" | entr tail -n 1 "${iibase}/${channel}/out" \
       +        | sed -nu 's,[0-9]* <\([^ >]*\)> \(.*\),\1 \2,p' \
       +        | {
       +while read -r user text;
       +do
       +        case "${channel}" in
       +        \#bitreich-radio)
       +                annna-message-radio "${channel}" "${user}" "${text}"
       +                ;;
       +        *)
       +                annna-message-common "${channel}" "${user}" "${text}"
       +                ;;
       +        esac
       +done
       +}
   DIR diff --git a/annna-start-services b/annna-start-services
       @@ -28,27 +28,9 @@ do
                [ -p "${iibase}/${channel}/in" ] \
                        && chmod o+w "${iibase}/${channel}/in"
        
       -        if [ ! -f "${iibase}/${channel}/out" ];
       +        if [ -f "${iibase}/${channel}/out" ];
                then
       -                continue
       +                annna-channel-service "${server}" "${channel}" &
                fi
       -
       -        {
       -                ls "${iibase}/${channel}/out" | entr tail -n 1 "${iibase}/${channel}/out" \
       -                        | sed -nu 's,[0-9]* <\([^ >]*\)> \(.*\),\1 \2,p' \
       -                        | {
       -                while read -r user text;
       -                do
       -                        case "${channel}" in
       -                        \#bitreich-radio)
       -                                annna-message-radio "${channel}" "${user}" "${text}"
       -                                ;;
       -                        *)
       -                                annna-message-common "${channel}" "${user}" "${text}"
       -                                ;;
       -                        esac
       -                done
       -                }
       -        } &
        done