comparison launch_gnb.sh @ 8:29eeddd8ea62 draft

planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
author gga
date Tue, 20 Feb 2024 10:05:05 +0000
parents dfb2bc3aedbd
children a0358a5ab3ae
comparison
equal deleted inserted replaced
7:dfb2bc3aedbd 8:29eeddd8ea62
1 #!/bin/bash 1 #!/bin/bash
2 2
3 set -e 3 set -e
4 4
5 echo "Running mongod: " 5 # Make sure the file always exists even on first grep
6 touch mongod.log
7
8 echo "Starting mongod, listening on unix socket in $(pwd)"
6 mongod --dbpath ./mongo_db/ --unixSocketPrefix "$(pwd)" --bind_ip fake_socket --logpath ./mongod.log --pidfilepath ./mongo.pid & 9 mongod --dbpath ./mongo_db/ --unixSocketPrefix "$(pwd)" --bind_ip fake_socket --logpath ./mongod.log --pidfilepath ./mongo.pid &
7 10
8 echo "Waiting while mongod starts up" 11 echo "Waiting while mongod starts up"
9 12
10 tries=0 13 tries=0
24 done; 27 done;
25 28
26 TMP_STORAGE=$(pwd)/tmp_storage 29 TMP_STORAGE=$(pwd)/tmp_storage
27 mkdir "$TMP_STORAGE" 30 mkdir "$TMP_STORAGE"
28 31
32 # Make sure the file always exists
33 touch gnb.log
34
29 export NODE_OPTIONS="--max-old-space-size=$((${GALAXY_MEMORY_MB:-8192} * 75 / 100))" 35 export NODE_OPTIONS="--max-old-space-size=$((${GALAXY_MEMORY_MB:-8192} * 75 / 100))"
36
37 # Find free port at the last moment
38 export GNB_PORT=$(bash "$(dirname "${BASH_SOURCE[0]}")/find_free_port.sh")
39 echo "Mongod is ready, starting gnb now on port ${GNB_PORT} and with mongodb://${MONGO_URI}%2Fmongodb-27017.sock/genenotebook"
30 40
31 genoboo run --storage-path "$TMP_STORAGE" --port ${GNB_PORT} --mongo-url mongodb://$MONGO_URI%2Fmongodb-27017.sock/genenotebook > ./gnb.log 2>&1 & 41 genoboo run --storage-path "$TMP_STORAGE" --port ${GNB_PORT} --mongo-url mongodb://$MONGO_URI%2Fmongodb-27017.sock/genenotebook > ./gnb.log 2>&1 &
32 42
33 export GNB_PID=$! 43 export GNB_PID=$!
34 44
36 46
37 while ! grep -q "GeneNoteBook server started, serving" ./gnb.log; do 47 while ! grep -q "GeneNoteBook server started, serving" ./gnb.log; do
38 48
39 tries_gnb=$((tries_gnb + 1)) 49 tries_gnb=$((tries_gnb + 1))
40 50
41 if [ "$tries_gnb" -ge 30 ]; then 51 # GNB can take a while to start depending on storage (accessing many many small js files)
52 if [ "$tries_gnb" -ge 150 ]; then
42 echo "Failed to launch GeneNoteBook:" 1>&2; 53 echo "Failed to launch GeneNoteBook:" 1>&2;
43 cat ./gnb.log 1>&2; 54 cat ./gnb.log 1>&2;
44 kill $GNB_PID $(<"./mongo.pid"); 55 kill $GNB_PID $(<"./mongo.pid");
45 exit 1; 56 exit 1;
46 fi 57 fi
47 58
48 sleep 3 59 sleep 3
49 done; 60 done;
61
62 # Make sure that gnb is working, and that it's serving on the expected port
63 curl "http://127.0.0.1:${GNB_PORT}/healthcheck" > /dev/null
64 grep -q "Healthcheck OK" ./gnb.log
65
66 echo "GNB is ready"