mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-07 23:43:12 +00:00
refactor: startup (#56)
* refactor: polling chainid instead of sleeptime * feat: add check for queen container running
This commit is contained in:
parent
568f17465c
commit
7fb69c9b3f
@ -48,9 +48,17 @@ queen_failure() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_queen_is_running() {
|
||||||
|
QUEEN_RUNNING=$(docker container inspect -f "{{.State.Running}}" $QUEEN_CONTAINER_NAME)
|
||||||
|
if [ "$QUEEN_RUNNING" == 'false' ] ; then
|
||||||
|
echo "Queen container has been stopped... stop environment start process..."
|
||||||
|
queen_failure
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
fetch_queen_underlay_addr() {
|
fetch_queen_underlay_addr() {
|
||||||
if [[ -n "$QUEEN_UNDERLAY_ADDRESS" ]] ; then return; fi
|
if [[ -n "$QUEEN_UNDERLAY_ADDRESS" ]] ; then return; fi
|
||||||
|
check_queen_is_running
|
||||||
ELAPSED_TIME=0
|
ELAPSED_TIME=0
|
||||||
WAITING_TIME=5
|
WAITING_TIME=5
|
||||||
# Wait 2 mins for queen start
|
# Wait 2 mins for queen start
|
||||||
@ -271,6 +279,7 @@ ELAPSED_TIME=0
|
|||||||
WAITING_TIME=2
|
WAITING_TIME=2
|
||||||
TIMEOUT=$((2*30*WAITING_TIME))
|
TIMEOUT=$((2*30*WAITING_TIME))
|
||||||
while (( TIMEOUT > ELAPSED_TIME )) ; do
|
while (( TIMEOUT > ELAPSED_TIME )) ; do
|
||||||
|
check_queen_is_running
|
||||||
COUNT=$(count_connected_peers)
|
COUNT=$(count_connected_peers)
|
||||||
[[ $COUNT < $WORKERS ]] || break
|
[[ $COUNT < $WORKERS ]] || break
|
||||||
echo "Only $COUNT peers have been connected to the Queen Bee node yet. Waiting until $WORKERS"
|
echo "Only $COUNT peers have been connected to the Queen Bee node yet. Waiting until $WORKERS"
|
||||||
|
|||||||
@ -113,7 +113,12 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for blockchain service initializes
|
# Wait for blockchain service initializes
|
||||||
sleep 5
|
while : ; do
|
||||||
|
CHAINID=$(curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"eth_chainId","id":1}' http://localhost:9545 | grep "0xfb4")
|
||||||
|
[[ "$CHAINID" != '{"id":1,"jsonrpc":"2.0","result":"0xfb4"}' ]] || break
|
||||||
|
echo "waiting for blockchain service is up..."
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
# Build up bee.sh parameters
|
# Build up bee.sh parameters
|
||||||
BEE_SH_ARGUMENTS="--workers=$WORKERS --own-image --port-maps=$PORT_MAPS --hostname=$HOSTNAME"
|
BEE_SH_ARGUMENTS="--workers=$WORKERS --own-image --port-maps=$PORT_MAPS --hostname=$HOSTNAME"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user