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

Commit

Permalink
fix: add the ability to run the ui or api independently
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines authored and mergify[bot] committed Jul 5, 2019
1 parent d6b1651 commit 8609c11
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ yarn-error.log*

# redis
dump.rdb

# Logs generated by bin/blockexplorer.sh
solana-blockexplorer-api.log
solana-blockexplorer-ui.log
62 changes: 44 additions & 18 deletions bin/blockexplorer.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#!/usr/bin/env bash
set -e

cmd=${1:-all}
case $cmd in
ui)
runUi=1
runApi=0
;;
api)
runUi=0
runApi=1
;;
all)
runUi=1
runApi=1
;;
*)
echo "Error: unknown command: $cmd"
exit 1
;;
esac

cwd=$PWD

rootDir=$(
Expand Down Expand Up @@ -41,32 +61,38 @@ cleanup() {
}
trap cleanup SIGINT SIGTERM ERR

(
set -x
redis-cli ping
)
if ((runApi)); then
(
set -x
redis-cli ping
)
fi

rm -f "$cwd"/solana-blockexplorer-{api,ui}.log

api=
ui=
while true; do
if [[ -z $api ]] || ! kill -0 "$api"; then
logfile="$cwd"/solana-blockexplorer-api.log
echo "Starting api process (logfile: $logfile)"
date | tee -a "$logfile"
npm run start-prod:api >> "$logfile" 2>&1 &
api=$!
echo " pid: $api"
if ((runApi)); then
if [[ -z $api ]] || ! kill -0 "$api"; then
logfile="$cwd"/solana-blockexplorer-api.log
echo "Starting api process (logfile: $logfile)"
date | tee -a "$logfile"
npm run start-prod:api >> "$logfile" 2>&1 &
api=$!
echo " pid: $api"
fi
fi

if [[ -z $ui ]] || ! kill -0 "$ui"; then
logfile="$cwd"/solana-blockexplorer-ui.log
echo "Starting ui process (logfile: $logfile)"
date | tee -a "$logfile"
npm run start-prod:ui >> "$logfile" 2>&1 &
ui=$!
echo " pid: $ui"
if ((runUi)); then
if [[ -z $ui ]] || ! kill -0 "$ui"; then
logfile="$cwd"/solana-blockexplorer-ui.log
echo "Starting ui process (logfile: $logfile)"
date | tee -a "$logfile"
npm run start-prod:ui >> "$logfile" 2>&1 &
ui=$!
echo " pid: $ui"
fi
fi

sleep 1
Expand Down

0 comments on commit 8609c11

Please sign in to comment.