From af7b3997ed0b437348f3d1d0cb76d7e091a4cbed Mon Sep 17 00:00:00 2001 From: VG Date: Mon, 25 Apr 2016 17:37:08 +0200 Subject: Implement the teaqueue project. - readme has been completed. - teaqueue-server has been implemented. - teaqueue-client has been implemented. - some worker examples have been written. --- teaqueue-server | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 teaqueue-server (limited to 'teaqueue-server') diff --git a/teaqueue-server b/teaqueue-server new file mode 100755 index 0000000..02c8b6a --- /dev/null +++ b/teaqueue-server @@ -0,0 +1,53 @@ +#!/bin/bash +# use bash for trap + +set -eu + +# default options +queuefn="queue.txt" +donefn="done.txt" +port=1340 + +usage() +{ + cat <&2; exit 1; fi +eval set -- "$TEMP" +while true; do + case "$1" in + -h|--help) usage; exit 0;; + -p|--port) port="$2"; shift 2;; + -q|--queue) queuefn="$2"; shift 2;; + -d|--done) donefn="$2"; shift 2;; + --) shift; break;; + *) echo "Arguments parsing error" >&2; exit 1;; + esac +done + +my_exit() +{ + mv "${queuefn}" "${queuefn}.old" + comm --nocheck-order -23 "${queuefn}.old" "${donefn}" > "${queuefn}" + exit 0 +} + +trap my_exit SIGINT SIGTERM + +cat "${queuefn}" | while read -r line; do + printf "%s\n" "$line" | nc -q0 -l -p $port + printf "%s\n" "$line" +done > "${donefn}" -- cgit v1.2.3