forked from gadgetron/gadgetron
-
Notifications
You must be signed in to change notification settings - Fork 6
/
start_supervisor
executable file
·46 lines (41 loc) · 1.57 KB
/
start_supervisor
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
#!/bin/bash
#Make sure environment variables are set
export GADGETRON_SUPERVISOR_NODAEMON=${GADGETRON_SUPERVISOR_NODAEMON:-"true"}
export GADGETRON_RELAY_HOST=${GADGETRON_RELAY_HOST:-"127.0.0.1"}
export GADGETRON_LOG_FILENAME=${GADGETRON_LOG_FILENAME:-"/tmp/gadgetron.log"}
export OMP_THREAD_LIMIT=$(($(nproc)*2))
#export OMP_NUM_THREADS=$(nproc)
export OMP_WAIT_POLICY=passive
#export OMP_DYNAMIC=false
#export OMP_PROC_BIND=true
export OPENBLAS_NUM_THREADS=1
# if want to ensure high numerical reproducibility, turn on this option
# export MKL_CBWR=COMPATIBLE
# Find unused port
# Trick copied from https://unix.stackexchange.com/questions/55913
# The returned port might not really be free in case concurrent containers
# are running this piece of code at the same time. We allow for a few
# unsuccessfull trials to account for this.
NBTRIALS=5
#LOWER=9001 # Lower bound on searched port numbers
#UPPER=9099 # Upper bound on searched port numbers
read LOWER UPPER < /proc/sys/net/ipv4/ip_local_port_range
echo "LOWER: $LOWER / UPPER: $UPPER"
SUCCESS=0
for ((TRIAL=1; TRIAL<=$NBTRIALS; TRIAL++))
do
echo "Trying to launch gadgetron, trial $TRIAL..."
for ((SUPERVISORD_PORT =$LOWER; SUPERVISORD_PORT<=$UPPER; SUPERVISORD_PORT++))
do
export SUPERVISORD_PORT
echo "Trying port $SUPERVISORD_PORT..."
unlink /var/run/supervisor.sock
/usr/bin/supervisord -c /opt/supervisord.conf && SUCCESS=1 && break 2
done
done
if [ "$SUCCESS" = "1" ]
then
echo "Successfully launched supervisor on port $SUPERVISORD_PORT."
else
echo "Failed to launch supervisor."
fi