Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/ping-to-master
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-03-23 20:18:01 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-03-23 20:18:01 +0100
commitc30de005f885202f24929bd4e3d3f5c885efbc0a (patch)
tree44b512356b80d3adad6521ad74f38ff9271f6c0d /bin/ping-to-master
parentff768f012bfef1bf264d06214aead70a58c0ff90 (diff)
parent497779257683e1c4ee2f2bf4c25687b34323c6be (diff)
Merge branch 'master' into opcodes
Diffstat (limited to 'bin/ping-to-master')
-rwxr-xr-xbin/ping-to-master39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/ping-to-master b/bin/ping-to-master
new file mode 100755
index 0000000..15c9120
--- /dev/null
+++ b/bin/ping-to-master
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# periodically connects to the buildmaster to call ping-from slave to:
+# - report any update on the build process
+# - show that the build is still running
+# - get notified by the build master if the build is not necessary anymore
+
+# shellcheck source=conf/default.conf
+. "${0%/*}/../conf/default.conf"
+
+# TODO: abort build if requested to
+
+parent_pid="$1"
+parent_tmp_dir="$2"
+
+exec 9> "${work_dir}/ping-build-master.lock"
+
+while kill -0 "${parent_pid}" && \
+ [ -f "${parent_tmp_dir}/.ping-build-master" ]; do
+
+ # shellcheck disable=SC2029
+ find "${parent_tmp_dir}" \
+ -xdev \
+ -type f \
+ -name '*.build-log' \
+ -exec wc -l {} \; | \
+ sed 's, .*/, ,' | \
+ ssh \
+ -i "${master_build_server_identity}" \
+ -p "${master_build_server_port}" \
+ "${master_build_server_user}@${master_build_server}" \
+ 'ping-from-slave' "$(cat "${parent_tmp_dir}/.ping-build-master")"
+
+ # we wait upto 60 seconds to get the lock - if we get it, the parent
+ # must have released it and we're finished
+ if flock -w 60 9; then
+ break
+ fi
+done