aboutsummaryrefslogtreecommitdiffstats
path: root/teaqueue-client
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-04-25 17:37:08 +0200
committerVG <vg@devys.org>2016-04-25 17:37:08 +0200
commitaf7b3997ed0b437348f3d1d0cb76d7e091a4cbed (patch)
tree448771de191e377cc99991cdc422d75d28baf644 /teaqueue-client
parented613df3074cfeae80397cb61d142fe159b18e8c (diff)
downloadteaqueue-af7b3997ed0b437348f3d1d0cb76d7e091a4cbed.tar.gz
teaqueue-af7b3997ed0b437348f3d1d0cb76d7e091a4cbed.tar.bz2
teaqueue-af7b3997ed0b437348f3d1d0cb76d7e091a4cbed.zip
Implement the teaqueue project.
- readme has been completed. - teaqueue-server has been implemented. - teaqueue-client has been implemented. - some worker examples have been written.
Diffstat (limited to 'teaqueue-client')
-rwxr-xr-xteaqueue-client47
1 files changed, 47 insertions, 0 deletions
diff --git a/teaqueue-client b/teaqueue-client
new file mode 100755
index 0000000..c52d01e
--- /dev/null
+++ b/teaqueue-client
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+set -eu
+
+# default options
+host="127.0.0.1"
+port=1340
+retry_timeout=10
+
+usage()
+{
+ cat <<EOF
+Usage: $0 [OPTIONS...] command [args...]
+
+Connects to a teaqueue-server and call "command" with a line in stdin.
+
+Options:
+ -h, --help show usage
+ -H, --host what teaqueue-server host (default: 127.0.0.1)
+ -p, --port what port to use (default: 1340)
+EOF
+}
+
+# arg parsing
+TEMP=$(getopt -o hH:p: --long help,host,port -n teaqueue-client -- "$@")
+if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
+eval set -- "$TEMP"
+while true; do
+ case "$1" in
+ -h|--help) usage; exit 0;;
+ -H|--host) host="$2"; shift 2;;
+ -p|--port) port="$2"; shift 2;;
+ --) shift; break;;
+ *) echo "Arguments parsing error" >&2; exit 1;;
+ esac
+done
+
+if test $# -lt 1; then
+ echo "You must put a command to call" >&2; exit 1
+fi
+
+set +e
+
+while true; do
+ while ! nc -q0 "$host" "$port"; do sleep $retry_timeout; done | "$@"
+ sleep 1
+done