Add deployment for ADML agent with http interface
[anna.git] / example / diameter / launcher / deployments / aots-adml / stop.sh
diff --git a/example/diameter/launcher/deployments/aots-adml/stop.sh b/example/diameter/launcher/deployments/aots-adml/stop.sh
new file mode 100755 (executable)
index 0000000..a4f1121
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+function pgrep_live {
+  pids=$(pgrep "$1");
+  [ "$pids" ] || return;
+  ps -o s= -o pid= $pids | sed -n 's/^[^ZT][[:space:]]\+//p';
+}
+cd `dirname $0`
+PID=$(pgrep_live ^ADML)
+[ -z "$PID" ] && exit 0
+kill $PID
+
+# Protection to force kill (with SIGKILL) if ADML still alive after certain time:
+seconds2force=3
+count=$((10*seconds2force))
+kill0=0
+while [ $kill0 -eq 0 -a $count -gt 0 ]
+do
+  sleep 0.1
+  count=$((count-1))
+  kill -0 $PID 2>/dev/null
+  kill0=$?
+  echo -n .
+done
+[ $kill0 -eq 0 ] && { echo " sigkill to ADML pid $PID !" ; kill -9 $PID ; }
+rm -f .pid
+