-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgo.sh
executable file
·223 lines (191 loc) · 5.91 KB
/
go.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/env bash
tag=agvis:$USER
name=agvis_$USER
target=base
data=/Users/hcui7/tmp
registry=ltb.curent.utk.edu:5000
xauth=
entrypoint=
ipc=
net=host
user=1
cwd=1
interactive=1
script=
port=8810
pipindex=
piptrustedhost=
[ -f env.sh ] && . env.sh
build() {
# Set Agvis Branch
local BRANCH_NAME="master"
if [ "$1" ]; then
BRANCH_NAME=$1
fi
# Clone ANDES and DiME if they don't exist
if [ ! -d "../andes" ]; then
echo "Cloning ANDES repository..."
git clone https://github.com/cuihantao/andes.git ../andes
fi
if [ ! -d "../dime" ]; then
echo "Cloning DiME repository..."
git clone https://github.com/CURENT/dime.git ../dime
fi
# Copy ANDES and DiME to build directory
echo "Copying ANDES and DiME to build directory..."
cp -af ../andes .
cp -af ../dime .
# Build the Docker image
echo "Building Docker image $tag..."
docker build \
${target:+--target $target} \
${pipindex:+--build-arg PIP_INDEX_URL=$pipindex} \
${piptrustedhost:+--build-arg PIP_TRUSTED_HOST=$piptrustedhost} \
--build-arg BRANCH_NAME="$BRANCH_NAME" \
-t $tag .
}
run_tests() {
docker run -u root --rm $tag sh -c "cd tests && pytest"
}
dev2() {
google-chrome --incognito http://localhost:8810/ 2> /dev/null > /dev/null &
tmux split-window -v
tmux split-window -v
tmux select-layout tiled
tmux send-keys -t0 "docker run -u root --rm -t -p 8810:8810 $tag agvis run --host=0.0.0.0 --port $((port+0))" Enter
tmux send-keys -t1 "docker run --rm -t -v /tmp:/tmp -p 8818:8818 $tag dime -vv -l unix:/tmp/dime2 -l ws:$((port+8))" Enter
tmux send-keys -t2 "docker run -u root --rm -t -v /tmp:/tmp -v `pwd`/agvis/cases:/home/cui/work $tag andes run wecc.xlsx -r tds --dime-address ipc:///tmp/dime2"
}
clean() {
echo "Cleaning ANDES output file..."
andes misc -C --recursive
echo "Stopping and removing all Docker containers and images..."
if [ -n "$(docker ps -aq)" ]; then
docker stop $(docker ps -aq)
fi
if [ -n "$(docker ps -q)" ]; then
docker kill $(docker ps -q)
fi
if [ -n "$(docker images -a -q)" ]; then
docker rmi $(docker images -a -q)
fi
echo "Stopping all tmux sessions..."
tmux kill-server
echo "Removing DiME Unix domain sockets..."
if [ -e "/tmp/dime" ]; then
rm /tmp/dime
fi
if [ -e "/tmp/dime2" ]; then
rm /tmp/dime2
fi
echo "Cleaning completed."
}
run() {
if [ -n "$xauth" ]; then
rm -f $xauth
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $xauth nmerge -
fi
docker run --rm \
${interactive:+-it} \
${script:+-a stdin -a stdout -a stderr --sig-proxy=true} \
${ipc:+--ipc=$ipc} \
${net:+--net=$net} \
${user:+-u $(id -u):$(id -g)} \
${cwd:+-v $PWD:$PWD -w $PWD} \
${port:+-p $port:$port} \
${port2:+-p $port2:$port2} \
${data:+-v $data:$data} \
${xauth:+-e DISPLAY -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v /etc/shadow:/etc/shadow:ro -v /etc/sudoers.d:/etc/sudoers.d:ro -v $xauth:$xauth -e XAUTHORITY=$xauth} \
${entrypoint:+--entrypoint $entrypoint} \
$tag "$@"
}
run_8810() {
port=8810
net=
run "$@"
}
run_8811() {
port=8811
net=host
run "$@"
}
run_8812() {
port=8812
net=host
run "$@"
}
run_8819() {
port=8819
port2=8818
net=
run "$@"
}
inspect() {
entrypoint='/bin/bash -i' run "$@"
}
script() {
interactive= script=1 run "$@"
}
push() {
docker tag $tag $registry/$tag
docker push $registry/$tag
}
create() {
docker service create \
${name:+--name $name} \
${cwd:+--mount type=bind,src=$PWD,dst=$PWD} \
${data:+--mount type=bind,src=$data,dst=$data} \
$registry/$tag \
"$@"
}
destroy() {
docker service rm $name
}
logs() {
docker service logs $name "$@"
}
python() { python3 "$@"; }
python3() { run python3 -u "$@"; }
server() { python3 server.py --port=$port "$@"; }
andes() { run andes "$@"; }
reader() {
python benchmark.py --dime tcp://127.0.0.1:$port,reader,writer "$@" reader
}
writer() {
python benchmark.py --dime tcp://127.0.0.1:$port,writer,reader "$@" writer
}
dime() {
run dime ${1:-tcp://0.0.0.0:8819} --debug
}
dev-benchmark() {
tmux split-window -v
tmux split-window -v
tmux send-keys -t0 "#./go.sh dime" Enter
tmux send-keys -t1 "#./go.sh reader" Enter
tmux send-keys -t2 "#./go.sh writer" Enter
}
dev() {
google-chrome --incognito http://localhost:8810/ 2> /dev/null > /dev/null &
tmux split-window -v
tmux split-window -v
tmux select-layout tiled
tmux send-keys -t0 "docker run --rm -t -p 8810:8810 $tag gunicorn -w=1 -b 0.0.0.0:$((port+0)) agvis.app:app" Enter
tmux send-keys -t1 "docker run --rm -t -v /tmp:/tmp -p 8818:8818 $tag dime -vv -l unix:/tmp/dime2 -l ws:$((port+8))" Enter
tmux send-keys -t2 "docker run --rm -t -v /tmp:/tmp -v `pwd`/cases:/home/cui/work $tag andes -v 10 run wecc_vis.xlsx -r tds"
}
dime-cygwin() {
docker run --rm -it -p 5000:5000 -p 8818:8818 $tag dime -vv -l tcp:5000 -l ws:$((port+8))
}
"$@"
####################################################################################################
# DEPRECATED
####################################################################################################
# dev-cygwin() {
# google-chrome --incognito http://localhost:8810/ 2> /dev/null > /dev/null &
# mintty --exec "docker run --rm -t -v C:/cygwin64/`pwd`/static:/srv -p 8810:8810 $tag python3 -m http.server -d /srv $((port+0))" &
# mintty --exec "docker run --rm -t -p 5000:5000 -p 8818:8818 $tag dime -vv -l tcp:5000 -l ws:$((port+8))" &
# #mintty --exec "docker run --rm -t $tag andes -v 10 run /home/cui/wecc_vis.xlsx --dime tcp://127.0.0.1:5000 -r tds" &
# }
# http-cygwin() {
# docker run --rm -it -v C:/cygwin64/`pwd`/static:/srv -p 8810:8810 $tag python3 -m http.server -d /srv $((port+0))
# }