Skip to content

Commit

Permalink
Added vm host watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Jun 28, 2024
1 parent 9835290 commit 2c927a2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dmoj/scripts/vm-host-problem-watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

problem_storage_root="$(realpath "$1")"
judge_hosts_file="$(realpath "$2")"

cd $(dirname $0) || exit

. ./scripts/utils/notify

echo "$(date): Start watching ${problem_storage_root}, notifying ${judge_hosts_file}"

inotifywait -rm "${problem_storage_root}" -e move,create,delete -q | while read -r line; do
if [ "$(echo "$line" | cut -d' ' -f3)" != "init.yml" ]; then
continue
fi

notify "Judge problems updated"
echo "$(date): Update problems [$line]"
readarray -t judges < "${judge_hosts_file}"
for judge in "${judges[@]}"; do
curl -4 -s -X POST "http://$judge/update/problems" | sed "s/^/$(date) [$judge]: /"';$a\'
done
done

0 comments on commit 2c927a2

Please sign in to comment.