Ensure validator process is killed when fullnode.sh is killed (#4869)
automerge
This commit is contained in:
parent
0fa1af5d47
commit
76413cbfac
|
@ -793,7 +793,8 @@ pub fn run(
|
||||||
Ok(true) => {
|
Ok(true) => {
|
||||||
// Update successful, kill current process so it will be restart
|
// Update successful, kill current process so it will be restart
|
||||||
if let Some(ref mut child) = child_option {
|
if let Some(ref mut child) = child_option {
|
||||||
println!("Killing program: {:?}", child.kill());
|
let id = child.id();
|
||||||
|
println!("Killing pid {}: {:?}", id, child.kill());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(false) => {} // No update available
|
Ok(false) => {} // No update available
|
||||||
|
|
|
@ -402,8 +402,20 @@ new_gensis_block() {
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
PS4="$(basename "$0"): "
|
PS4="$(basename "$0"): "
|
||||||
|
|
||||||
pid=
|
pid=
|
||||||
trap '[[ -n $pid ]] && kill "$pid" >/dev/null 2>&1 && wait "$pid"' INT TERM ERR
|
kill_fullnode() {
|
||||||
|
if [[ -n $pid ]]; then
|
||||||
|
declare _pid=$pid
|
||||||
|
pid=
|
||||||
|
echo "killing pid $_pid"
|
||||||
|
kill "$_pid" || true
|
||||||
|
wait "$_pid" || true
|
||||||
|
echo "$_pid killed"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap 'kill_fullnode' INT TERM ERR
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if new_gensis_block; then
|
if new_gensis_block; then
|
||||||
# If the genesis block has changed remove the now stale ledger and vote
|
# If the genesis block has changed remove the now stale ledger and vote
|
||||||
|
@ -464,6 +476,7 @@ while true; do
|
||||||
echo "$PS4$program ${args[*]}"
|
echo "$PS4$program ${args[*]}"
|
||||||
$program "${args[@]}" &
|
$program "${args[@]}" &
|
||||||
pid=$!
|
pid=$!
|
||||||
|
echo "pid: $pid"
|
||||||
oom_score_adj "$pid" 1000
|
oom_score_adj "$pid" 1000
|
||||||
|
|
||||||
if ((no_restart)); then
|
if ((no_restart)); then
|
||||||
|
@ -517,15 +530,16 @@ while true; do
|
||||||
) || (
|
) || (
|
||||||
echo "Error: failed to rsync ledger"
|
echo "Error: failed to rsync ledger"
|
||||||
)
|
)
|
||||||
new_gensis_block && break
|
if new_gensis_block; then
|
||||||
|
echo "############## New genesis detected, restarting $node_type ##############"
|
||||||
|
break
|
||||||
|
fi
|
||||||
secs_to_next_genesis_poll=60
|
secs_to_next_genesis_poll=60
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "############## New genesis detected, restarting $node_type ##############"
|
kill_fullnode
|
||||||
kill "$pid" || true
|
|
||||||
wait "$pid" || true
|
|
||||||
# give the cluster time to come back up
|
# give the cluster time to come back up
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
|
|
Loading…
Reference in New Issue