ceremonyclient/node/poor_mans_cd.sh

42 lines
668 B
Bash
Raw Normal View History

2024-01-03 07:31:42 +00:00
#!/bin/bash
start_process() {
GOEXPERIMENT=arenas go run ./... &
2024-01-03 07:31:42 +00:00
process_pid=$!
child_process_pid=$(pgrep -P $process_pid)
}
is_process_running() {
ps -p $process_pid > /dev/null 2>&1
return $?
}
kill_process() {
kill $process_pid
kill $child_process_pid
}
start_process
while true; do
if ! is_process_running; then
echo "Process crashed or stopped. Restarting..."
start_process
fi
git fetch
local_head=$(git rev-parse HEAD)
remote_head=$(git rev-parse @{u})
if [ "$local_head" != "$remote_head" ]; then
kill_process
git pull
start_process
fi
sleep 60
done