Commit b7608c7e authored by phil's avatar phil

working nicely now

parent f262b88b
......@@ -13,8 +13,9 @@ REGISTER="$PUBSUB_BASE/subscribers.reg"
TARGET=$1
MESSAGE=$2
ID=$$
INDEX="$PUBSUB_BASE/subscribers.idx"
NEW_INDEX="$INDEX-$ID"
# create register if it does not exist
if [ ! -p "$REGISTER" ]; then
......@@ -37,11 +38,10 @@ for SUBSCRIBER in $SUBSCRIBERS; do
if [ -p "$SUBSCRIBER_PATH" ]; then
echo "publish to $SUBSCRIBER_PATH"
echo "$MESSAGE" >> "$SUBSCRIBER_PATH"
else
echo "TODO drop entry $SUBSCRIBER from INDEX"
echo "$SUBSCRIBER" >> "$NEW_INDEX"
fi
fi
done
echo "write index"
echo "$SUBSCRIBERS" > "$INDEX"
cp "$NEW_INDEX" "$INDEX"
rm "$NEW_INDEX"
......@@ -30,8 +30,18 @@ echo "$CHANNEL-$ID" >> "$REGISTER"
# echo "$LINE" | "$COMMAND"
# done < "$CHANNEL_PATH"
# do this repeatedly
"$COMMAND" < "$CHANNEL_PATH"
# TODO trap SIGINT & on exit `rm $CHANNEL_PATH`
rm "$CHANNEL_PATH"
do_exit() {
echo 'Cleaning up...'
rm "$CHANNEL_PATH"
exit 0
}
trap do_exit INT
echo "Press [CTRL+C] to stop."
echo "Listen to events on channel $CHANNEL..."
# do it repeatedly
while true
do
"$COMMAND" < "$CHANNEL_PATH"
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment