forked from qfo/benchmark-webservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy
executable file
·140 lines (122 loc) · 4.3 KB
/
deploy
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
target="$1"
share_path="${2:-/pub/projects/cbrg-ortholog-benchmark-service}"
usage() {
echo "Usage: $0 target_user@target_host [remote_share_path]"
}
die_usage() {
usage
exit 1
}
[ -n "$target" ] || die_usage
project="benchmark-webservice"
cat | ssh $target "cat | bash" << DONE
MAINHOST=$(dnsdomainname | grep -P "ethz.ch|ucl.ac.uk" >/dev/null)$?
if [ -d ~/$project ]; then
(cd ~/$project; git pull)
else
if [[ \$MAINHOST == 0 ]]; then
git clone [email protected]:$project
else
git clone https://github.com/qfo/${project}.git
fi
fi
# copy darwin binary and library
if [[ \$MAINHOST == 0 ]]; then
mkdir -p ~/darwin/DB
scp [email protected]:v2/source/linux64/darwin ~/darwin/darwin
scp -r [email protected]:v2/source/lib ~/darwin/
scp [email protected]:DB/GOdata.drw.gz ~/darwin/DB/
scp [email protected]:DB/speciescode.drw.gz ~/darwin/DB/
else
wget -O \${HOME}/darwin.tgz http://orthology.benchmark-service.org/darwin.tgz
(cd \${HOME}; tar xzf darwin.tgz; rm -f darwin.tgz)
fi
sed -i -e "s|datadirname\s*:=.*|datadirname := '\${HOME}/darwin/DB':|" ~/darwin/lib/darwinit
# create script to launch darwin in bin dir
mkdir -p ~/bin
cat > ~/bin/darwin <<EOF
#!/bin/bash
ulimit -s unlimited
exec ~/darwin/darwin -l ~/darwin/lib/ \\\$*
EOF
chmod +x ~/bin/darwin
if [ -h ~/bin/darwin64 ] ; then
unlink ~/bin/darwin64
fi
ln -s ~/bin/darwin ~/bin/darwin64
cat > ~/bin/start.$project <<EOX
#!/bin/bash
# source related environment variables
. ~/.bashrc
mkdir -p "/tmp/BS_outpipes"
if [ ! -p \${DARWIN_RUN_PATH}/BSin.\$(hostname) ]; then
rm -f \${DARWIN_RUN_PATH}/BSin.\$(hostname)
mkfifo \${DARWIN_RUN_PATH}/BSin.\$(hostname)
fi
debug="false"
if [[ "\\\$1" == "-d" ]] ; then
debug="true";
fi
exec darwin << EOY
DEBUG := \\\${debug};
ReadProgram( getenv('DARWIN_ORTHOLOG_BENCHMARK_REPO_PATH').'/ServerMain.drw' );
EOY
EOX
chmod +x ~/bin/start.$project
cat > ~/.bashrc << EOA
export DARWIN_ORTHOLOG_BENCHMARK_REPO_PATH=\${HOME}/$project
export DARWIN_LOG_PATH=\${HOME}/log
export DARWIN_RUN_PATH=\${HOME}/run
export DARWIN_ORTHOLOG_BENCHMARKDATA_PATH=${share_path}
export DARWIN_OMA_REPO_PATH=\${HOME}/OMA
echo \\\$PATH | grep -q \$HOME/bin || export PATH="\$HOME/bin:\\\$PATH"
export MAFFT_BINARIES=/usr/lib/mafft/lib/mafft
export GDFONTPATH="/usr/share/fonts/truetype/freefont/"
EOA
# make all directories and symlinks
. ~/.bashrc
DDIR="\${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/data/"
mkdir -p \$DDIR
if [ ! -f \${DDIR}/testProperties.drw ] ; then
echo "TESTPROPERTIES := table(0):" > \${DDIR}/testProperties.drw
fi
if [ ! -f \${DDIR}/projectKeys.drw ] ; then
echo "PROJECTS := table(0):" > \${DDIR}/projectKeys.drw
fi
mkdir -p \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/{results,sessions,projects,htdocs}
mkdir -p \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/htdocs/resultimgs
mkdir -p \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/htdocs/raw/{RefPhylo,EC,STDTest,GO,TreeTest}
for f in raw resultimgs examples simdata doc ; do
ln -s \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/htdocs/\${f} ~/$project/htdocs/\${f}
done
cat > ~/etc/supervisor.d/$project.conf << EOC
[fcgi-program:fcgiwrap]
command = /usr/sbin/fcgiwrap
numprocs = 2
process_name=%(program_name)s_%(process_num)02d
environment=DARWIN_RUN_PATH='\${HOME}/run',DARWIN_LOG_PATH='\${HOME}/log',DARWIN_ORTHOLOG_BENCHMARKDATA_PATH='\$DARWIN_ORTHOLOG_BENCHMARKDATA_PATH'
socket = unix://\${HOME}/run/fcgiwrap.socket
socket_owner = cbrg-obs:www-data
socket_mode = 0770
stdout_logfile = \${HOME}/log/%(program_name)s.log
stderr_logfile = \${HOME}/log/%(program_name)s.log
redirect_stderr = true
[program:$project]
command = \${HOME}/bin/start.$project
autorestart = true
stdout_logfile = \$HOME/log/%(program_name)s.log
stderr_logfile = \$HOME/log/%(program_name)s.log
redirect_stderr = true
EOC
# retrieve initial data to run benchmarking service on reference proteomes
if [ ! -f \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/reference5/ServerIndexed.db ] ; then
wget -O \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}/init_data.tgz http://orthology.benchmark-service.org/init_data.tgz
if [[ "$?" -ne "0" ]] ; then
echo "WARNING: cannot retrieve initial dataset from server."
else
(cd \${DARWIN_ORTHOLOG_BENCHMARKDATA_PATH}; tar xzf init_data.tgz; rm -f init_data.tgz)
fi
fi
./bin/svctl reload
DONE