-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_run_v1.sh
executable file
·68 lines (48 loc) · 1.18 KB
/
_run_v1.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
#!/bin/sh
set -e
# set -x
ulimit -c unlimited
# # Maybe (because there are problems with setuid sometimes):
# sudo ./.env/bin/uwsgi --ini _uwsgi.ini --logto _uwsgi.log &
. ./.env/bin/activate
python setup.py build_ext --inplace
./.env/bin/uwsgi --ini uwsgi_aeo.ini &
uwsgi_pid=$!
echo " ===== run: uWSGI pid: $uwsgi_pid"
trap 'kill -TERM "$uwsgi_pid" 2>/dev/null; sleep 2; kill -KILL "$uwsgi_pid" 2>/dev/null' EXIT
sleep 3
# # Maybe: nginx
# # (but hopefully uwsgi's http will be enough)
query="$1"
curl \
--fail \
--show-error \
--silent \
--max-time 20 \
"http://127.0.0.1:49053/test/?$query"
# echo " ===== run: Reload ..."
# echo w > ./.run/_uwsgi_master.fifo
# sleep 1
echo " ===== run: ..."
for num in $(seq 1 20); do
echo ""
curl \
--write-out "\nHTTP %{http_code}\n" \
--show-error \
--silent \
--max-time 20 \
"http://127.0.0.1:49053/test/?$query" \
|| true
if [ x"$num" = x"10" ]; then
echo "Mid-pause..."
sleep 10
else
sleep 0.01
fi
done
echo " ===== run: Sleep && kill..."
sleep 2
kill -TERM $uwsgi_pid
sleep 2
kill -KILL $uwsgi_pid || true
echo " ===== run: Done."