rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 285751d94f597ac0f83bae2fc165247b14223d57 963 bytes (raw)
$ git show v0.3.0:t/lib-async-response.sh	# shows this blob on the CLI

 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
 
CONFIG_RU=${CONFIG_RU-'async-response.ru'}
. ./test-lib.sh
echo "async response for model=$model"
eval $(unused_listen)
rtmpfiles unicorn_config a b c r_err r_out pid curl_err

cat > $unicorn_config <<EOF
listen "$listen"
stderr_path "$r_err"
stdout_path "$r_out"
pid "$pid"
Rainbows! { use :$model }
EOF

# can't load Rack::Lint here since it'll cause Rev to slurp
rainbows -E none -D $CONFIG_RU -c $unicorn_config
wait_for_pid $pid

t0=$(date +%s)
( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $a) &
( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $b) &
( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $c) &
wait
t1=$(date +%s)

rainbows_pid=$(cat $pid)
kill -QUIT $rainbows_pid
elapsed=$(( $t1 - $t0 ))
echo "elapsed=$elapsed < 30"
test $elapsed -lt 30

dbgcat a
dbgcat b
dbgcat c
dbgcat r_err
dbgcat curl_err
test ! -s $curl_err
check_stderr

while kill -0 $rainbows_pid >/dev/null 2>&1
do
	sleep 1
done

dbgcat r_err

git clone https://yhbt.net/rainbows.git