Skip to content

Commit

Permalink
rework daemon waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
abretaud committed Feb 1, 2024
1 parent 72331c3 commit 04881c4
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions tools/genenotebook/launch_gnb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@

set -e

mongod --dbpath ./mongo_db/ --unixSocketPrefix `pwd` --bind_ip fake_socket --logpath ./mongod.log --pidfilepath ./mongo.pid &
echo "Running mongod: "
mongod --dbpath ./mongo_db/ --unixSocketPrefix "$(pwd)" --bind_ip fake_socket --logpath ./mongod.log --pidfilepath ./mongo.pid &

sleep 15
echo "Waiting while mongod starts up"

tries=0

# "Listening on" is for mongodb 5x
if ! grep -q "Listening on" ./mongod.log; then
echo "Failed to launch MongoDB:" 1>&2;
cat ./mongod.log 1>&2;
kill $GNB_PID;
exit 1;
fi;
while ! grep -q "Listening on" ./mongod.log; do

tries=$((tries + 1))

if [ "$tries" -ge 30 ]; then
echo "Failed to launch MongoDB:" 1>&2;
cat ./mongod.log 1>&2;
exit 1;
fi

sleep 3
done;

TMP_STORAGE=$(pwd)/tmp_storage
mkdir "$TMP_STORAGE"
Expand All @@ -23,11 +32,18 @@ genoboo run --storage-path "$TMP_STORAGE" --port ${GNB_PORT} --mongo-url mongodb

export GNB_PID=$!

sleep 15
tries_gnb=0

while ! grep -q "GeneNoteBook server started, serving" ./gnb.log; do

tries_gnb=$((tries_gnb + 1))

if [ "$tries_gnb" -ge 30 ]; then
echo "Failed to launch GeneNoteBook:" 1>&2;
cat ./gnb.log 1>&2;
kill $GNB_PID $(<"./mongo.pid");
exit 1;
fi

if ! grep -q "GeneNoteBook server started, serving" ./gnb.log; then
echo "Failed to launch GeneNoteBook:" 1>&2;
cat ./gnb.log 1>&2;
kill $GNB_PID $(<"./mongo.pid");
exit 1;
fi;
sleep 3
done;

0 comments on commit 04881c4

Please sign in to comment.