Skip to content

Commit d905297

Browse files
authored
Merge pull request #122 from blinklabs-io/fix/mithril-client-sigterm
fix: allow SIGTERM for mithril-client
2 parents 52acdf0 + 12dfa28 commit d905297

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

bin/run-network

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ if ! test -e /data/db/protocolMagicId; then
2727
mkdir -p /data
2828
cd /data
2929
echo "Starting: /usr/local/bin/mithril-client snapshot download ${SNAPSHOT_DIGEST}"
30-
mithril-client snapshot download ${SNAPSHOT_DIGEST}
30+
# Handle SIGTERM during initial sync
31+
trap 'kill -TERM $(pidof mithril-client)' TERM
32+
# Run mithril-client in the background so we can capture the PID and wait
33+
mithril-client snapshot download ${SNAPSHOT_DIGEST} &
34+
_mithril_pid=$!
35+
wait $_mithril_pid || exit $?
36+
# Reset signal handler and wait again (to avoid race condition)
37+
trap - TERM
38+
wait $_mithril_pid || exit $?
3139
fi
3240
fi
3341

bin/run-node

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ if ! test -e ${CARDANO_DATABASE_PATH}/protocolMagicId; then
9494
if [[ $(cd ${CARDANO_DATABASE_PATH}; pwd -P) != $(pwd -P)/db ]]; then
9595
rm -rf db/*
9696
fi
97-
mithril-client snapshot download ${SNAPSHOT_DIGEST}
97+
# Handle SIGTERM during initial sync
98+
trap 'kill -TERM $(pidof mithril-client)' TERM
99+
# Run mithril-client in the background so we can capture the PID and wait
100+
mithril-client snapshot download ${SNAPSHOT_DIGEST} &
101+
_mithril_pid=$!
102+
wait $_mithril_pid || exit $?
103+
# Reset signal handler and wait again (to avoid race condition)
104+
trap - TERM
105+
wait $_mithril_pid || exit $?
98106
if [[ $(cd ${CARDANO_DATABASE_PATH}; pwd -P) != $(pwd -P)/db ]]; then
99107
mv -f db/* ${CARDANO_DATABASE_PATH}/
100108
fi

0 commit comments

Comments
 (0)