ceremonyclient/node/poor_mans_cd.sh
Cassandra Heart 2e2a1e4789
v1.2.0 (#31)
2024-01-03 01:31:42 -06:00

42 lines
648 B
Bash
Executable File

#!/bin/bash
start_process() {
go run ./... &
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