coolio+xepoll_thread*: use shutdown() for keepalive timeout
[rainbows.git] / t / t0015-working_directory.sh
blob26e501a60d35e8d473d6adf859c6d67114c58764
1 #!/bin/sh
2 if test -n "$RBX_SKIP"
3 then
4 echo "$0 is broken under Rubinius for now"
5 exit 0
6 fi
7 . ./test-lib.sh
9 t_plan 6 "config.ru inside alt working_directory"
11 t_begin "setup and start" && {
12 rainbows_setup
13 rtmpfiles unicorn_config_tmp
14 rm -rf $t_pfx.app
15 mkdir $t_pfx.app
17 cat > $t_pfx.app/config.ru <<EOF
18 #\--daemonize --listen $listen
19 use Rack::ContentLength
20 use Rack::ContentType, "text/plain"
21 run lambda { |env| [ 200, {}, [ "#{\$master_ppid}\\n" ] ] }
22 EOF
23 # we have --host/--port in config.ru instead
24 grep -v ^listen $unicorn_config > $unicorn_config_tmp
26 # the whole point of this exercise
27 echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
29 # allows ppid to be 1 in before_fork
30 echo "preload_app true" >> $unicorn_config_tmp
31 cat >> $unicorn_config_tmp <<\EOF
32 before_fork do |server,worker|
33 $master_ppid = Process.ppid # should be zero to detect daemonization
34 end
35 EOF
37 mv $unicorn_config_tmp $unicorn_config
39 # rely on --daemonize switch, no & or -D
40 rainbows -c $unicorn_config
41 rainbows_wait_start
44 t_begin "reload to avoid race condition" && {
45 curl -sSf http://$listen/ >/dev/null
46 kill -HUP $rainbows_pid
47 test xSTART = x"$(cat $fifo)"
50 t_begin "hit with curl" && {
51 body=$(curl -sSf http://$listen/)
54 t_begin "killing succeeds" && {
55 kill $rainbows_pid
58 t_begin "response body ppid == 1 (daemonized)" && {
59 test "$body" -eq 1
62 t_begin "cleanup working directory" && {
63 rm -r $t_pfx.app
66 t_done