-
Notifications
You must be signed in to change notification settings - Fork 2
/
cromwellServer.sh
executable file
·75 lines (67 loc) · 2.36 KB
/
cromwellServer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
source /app/lmod/lmod/init/bash
module use /app/modules/all
# grab all your customization variables for this env
source ${2}
# run this python chunk to find an open port on the node
ml Python
CROMWELLPORT=$( python3 <<CODE
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 0))
addr = s.getsockname()
print(addr[1])
s.close()
CODE
)
# send this port and hostname back to the user
echo "Your Cromwell server is attempting to start up at http://$(hostname):$CROMWELLPORT. \
It can take up to 2 minutes prior to the port being open for use by the shiny app at https://cromwellapp.fredhutch.org or via the R package rcromwell. \
If you encounter errors, you may want to check your server logs at "$SERVERLOGDIR" to see if Cromwell was unable to start up." | nc -N ${SLURM_SUBMIT_HOST} ${MYPORT}
# Clean the env
module purge
# Load the Cromwell Module
module --ignore-cache load cromwell/84
# All this to make it a little more readable. Put JDBC connection
# options in a bash array
jdbc_options=(\
rewriteBatchedStatements=true \
serverTimezone=UTC \
)
# Then encode for URL (ampersands and all that)
# see here: https://stackoverflow.com/questions/1527049/how-can-i-join-elements-of-an-array-in-bash
jdbc_connect_params=$(IFS=\& ; echo "${jdbc_options[*]}")
# Ensure scratch dir exists
if [ ! -d ${SCRATCHDIR} ]; then
mkdir -p ${SCRATCHDIR}
fi
SCRATCHPATH=${SCRATCHDIR}/cromwell-executions
# Ensure scratch path exists
if [ ! -d ${SCRATCHPATH} ]; then
mkdir -p ${SCRATCHPATH}
fi
# Ensure workflow log dir exists
if [ ! -d ${WORKFLOWLOGDIR} ]; then
mkdir -p ${WORKFLOWLOGDIR}
fi
# Ensure Singularity cache dir exists
SINGULARITYCACHEDIR=${SCRATCHPATH}/.singularity-cache
if [ ! -d ${SINGULARITYCACHEDIR} ]; then
mkdir -p ${SINGULARITYCACHEDIR}
fi
export SINGULARITYCACHEDIR
# Run your server!
java -Xms28g -Xmx31g \
-XX:+UseParallelGC \
-XX:ParallelGCThreads=${NCORES} \
-Dconfig.file=${1} \
-DLOG_MODE=pretty \
-DLOG_LEVEL=WARN \
-Dbackend.providers.gizmo.config.root=${SCRATCHPATH} \
-Dworkflow-options.workflow-log-dir=${WORKFLOWLOGDIR} \
-Ddatabase.db.url=jdbc:mysql://mydb:${CROMWELLDBPORT}/${CROMWELLDBNAME}?${jdbc_connect_params} \
-Ddatabase.db.user=${CROMWELLDBUSERNAME} \
-Ddatabase.db.password=${CROMWELLDBPASSWORD} \
-Dwebservice.port=${CROMWELLPORT} \
-jar $EBROOTCROMWELL/cromwell.jar \
server