socket_helper: move defaults to the DEFAULTS constant
[unicorn.git] / t / t0007-working_directory_no_embed_cli.sh
blob77d670721aefcbf6047e9100a38426721cddba85
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 4 "config.ru inside alt working_directory (no embedded switches)"
6 t_begin "setup and start" && {
7 unicorn_setup
8 rm -rf $t_pfx.app
9 mkdir $t_pfx.app
11 cat > $t_pfx.app/config.ru <<EOF
12 use Rack::ContentLength
13 use Rack::ContentType, "text/plain"
14 run lambda { |env| [ 200, {}, [ "#{\$master_ppid}\\n" ] ] }
15 EOF
16 # the whole point of this exercise
17 echo "working_directory '$t_pfx.app'" >> $unicorn_config
19 # allows ppid to be 1 in before_fork
20 echo "preload_app true" >> $unicorn_config
21 cat >> $unicorn_config <<\EOF
22 before_fork do |server,worker|
23 $master_ppid = Process.ppid # should be zero to detect daemonization
24 end
25 EOF
27 cd /
28 unicorn -D -c $unicorn_config
29 unicorn_wait_start
32 t_begin "hit with curl" && {
33 body=$(curl -sSf http://$listen/)
36 t_begin "killing succeeds" && {
37 kill $unicorn_pid
40 t_begin "response body ppid == 1 (daemonized)" && {
41 test "$body" -eq 1
44 t_done