annotate launch_gnb.sh @ 11:4398a6fea625 draft default tip

planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 6b276b84437470f019a6b13a7bd17171c117cece
author gga
date Mon, 01 Jul 2024 08:44:45 +0000
parents a0358a5ab3ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
1 #!/bin/bash
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
2
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
3 set -e
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
4
8
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
5 # Make sure the file always exists even on first grep
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
6 touch mongod.log
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
7
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
8 echo "Starting mongod, listening on unix socket in $(pwd)"
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
9 mongod --dbpath ./mongo_db/ --unixSocketPrefix "$(pwd)" --bind_ip fake_socket --logpath ./mongod.log --pidfilepath ./mongo.pid &
0
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
10
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
11 echo "Waiting while mongod starts up"
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
12
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
13 tries=0
0
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
14
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
15 # "Listening on" is for mongodb 5x
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
16 while ! grep -q "Listening on" ./mongod.log; do
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
17
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
18 tries=$((tries + 1))
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
19
11
4398a6fea625 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 6b276b84437470f019a6b13a7bd17171c117cece
gga
parents: 10
diff changeset
20 if [ "$tries" -ge 50 ]; then
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
21 echo "Failed to launch MongoDB:" 1>&2;
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
22 cat ./mongod.log 1>&2;
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
23 exit 1;
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
24 fi
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
25
11
4398a6fea625 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 6b276b84437470f019a6b13a7bd17171c117cece
gga
parents: 10
diff changeset
26 sleep 5
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
27 done;
0
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
28
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
29 TMP_STORAGE=$(pwd)/tmp_storage
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
30 mkdir "$TMP_STORAGE"
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
31
8
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
32 # Make sure the file always exists
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
33 touch gnb.log
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
34
2
5a6050937cb9 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit ec3c633a0751bb9e253bcd77fea425180c9a0014
gga
parents: 1
diff changeset
35 export NODE_OPTIONS="--max-old-space-size=$((${GALAXY_MEMORY_MB:-8192} * 75 / 100))"
5a6050937cb9 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit ec3c633a0751bb9e253bcd77fea425180c9a0014
gga
parents: 1
diff changeset
36
8
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
37 # Find free port at the last moment
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
38 export GNB_PORT=$(bash "$(dirname "${BASH_SOURCE[0]}")/find_free_port.sh")
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
39 echo "Mongod is ready, starting gnb now on port ${GNB_PORT} and with mongodb://${MONGO_URI}%2Fmongodb-27017.sock/genenotebook"
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
40
1
f415e44e71de planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit a04f273adbc0ebb95bf42bf5bad8b41ba7aba91d
gga
parents: 0
diff changeset
41 genoboo run --storage-path "$TMP_STORAGE" --port ${GNB_PORT} --mongo-url mongodb://$MONGO_URI%2Fmongodb-27017.sock/genenotebook > ./gnb.log 2>&1 &
0
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
42
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
43 export GNB_PID=$!
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
44
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
45 tries_gnb=0
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
46
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
47 while ! grep -q "GeneNoteBook server started, serving" ./gnb.log; do
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
48
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
49 tries_gnb=$((tries_gnb + 1))
0
22f22c3e81bf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents:
diff changeset
50
8
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
51 # GNB can take a while to start depending on storage (accessing many many small js files)
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
52 if [ "$tries_gnb" -ge 150 ]; then
7
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
53 echo "Failed to launch GeneNoteBook:" 1>&2;
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
54 cat ./gnb.log 1>&2;
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
55 kill $GNB_PID $(<"./mongo.pid");
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
56 exit 1;
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
57 fi
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
58
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
59 sleep 3
dfb2bc3aedbd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 91ccbf9f293fe6b183302841aa49e061c4ab3157
gga
parents: 2
diff changeset
60 done;
8
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
61
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
62 # Make sure that gnb is working, and that it's serving on the expected port
10
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
63 # Wait a bit for curl to work, just in case. Dump the logs if it does not
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
64
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
65 tries_curl=0
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
66
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
67 while ! curl -s "http://127.0.0.1:${GNB_PORT}/healthcheck"; do
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
68 tries_curl=$((tries_curl + 1))
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
69 if [ "$tries_curl" -ge 100 ]; then
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
70 echo "Healthcheck is not working, stopping:" 1>&2;
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
71 cat ./gnb.log 1>&2;
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
72 kill $GNB_PID $(<"./mongo.pid");
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
73 exit 1;
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
74 fi
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
75
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
76 sleep 3
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
77 done;
a0358a5ab3ae planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 0bc8333885dc11b283291458fb9d4bbd2052f6e0
gga
parents: 8
diff changeset
78
8
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
79 grep -q "Healthcheck OK" ./gnb.log
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
80
29eeddd8ea62 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/genenotebook commit 1429f00733ee24bf2edf56b9fd7ff4ad2dec3f15
gga
parents: 7
diff changeset
81 echo "GNB is ready"