Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
fix: improve blockexplorer.sh abort handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Feb 17, 2019
1 parent 97b1bd6 commit 72c6bee
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bin/blockexplorer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ if [[ ! -d build || ! -f build/api/api.js ]]; then
exit 1
fi

set -x
cleanup() {
set +e
for pid in "$api" "$ui"; do
[[ -z $pid ]] || kill "$pid"
done
}
trap cleanup SIGINT SIGTERM

set -x
redis-cli ping

node build/api/api.js &
Expand All @@ -30,10 +37,6 @@ api=$!
PORT=80 npx serve -s build &
ui=$!

abort() {
kill "$api" "$ui"
}

trap abort SIGINT SIGTERM
wait "$ui"
kill "$api" "$ui"
ui=
cleanup

0 comments on commit 72c6bee

Please sign in to comment.