summaryrefslogtreecommitdiffstats
path: root/mockrun
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-04-19 11:47:03 +0200
committerRemi Collet <remi@php.net>2024-04-19 11:47:03 +0200
commit9fc98148d850b35f9e47e33188639424dfa89e48 (patch)
tree65cfd2424ef6ad21ef8ef51d55186d39cbd8e7f1 /mockrun
parent1e7b3ee7cebffc20c1e9e14a97b3225d3315ac1e (diff)
add redis queue to mockit/mockrun
Diffstat (limited to 'mockrun')
-rwxr-xr-xmockrun41
1 files changed, 41 insertions, 0 deletions
diff --git a/mockrun b/mockrun
new file mode 100755
index 0000000..a303073
--- /dev/null
+++ b/mockrun
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+CHECK=$(redis-cli ping)
+[ "$CHECK" = "PONG" ] || exit 1
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ echo "Usage $0 [ option ]"
+ echo " -e --erase to empty the queue"
+ echo " -l --list to list the queue"
+ echo " -p --perm to run permanently"
+
+ exit 0
+
+elif [ "$1" = "-l" -o "$1" = "--list" ]; then
+ redis-cli smembers mock
+ exit 0
+
+elif [ "$1" = "-e" -o "$1" = "--erase" ]; then
+ redis-cli del mock
+ exit 0
+fi
+
+while true
+do
+ CMD=$(redis-cli spop mock)
+ if [ -z "$CMD" ]; then
+ if [ "$1" = "-p" -o "$1" = "--perm" ]; then
+ echo -n .
+ sleep 1
+ continue
+ else
+ break
+ fi
+ fi
+ TXT=$(echo $CMD | sed -e 's/^.*-r //;s/ .*$//')
+ echo -en "\r$(date +%X) $TXT "
+ $CMD --uniqueext=$PPID && echo " Ok." || echo " Error !"
+done
+
+echo "$(date +%X) Done"
+