4 t_plan
4 "config.ru inside alt working_directory"
6 t_begin
"setup and start" && {
8 rtmpfiles unicorn_config_tmp
12 cat > $t_pfx.app
/config.ru
<<EOF
13 #\--daemonize --host $host --port $port
14 use Rack::ContentLength
15 use Rack::ContentType, "text/plain"
16 run lambda { |env| [ 200, {}, [ "#{\$master_ppid}\\n" ] ] }
18 # we have --host/--port in config.ru instead
19 grep -v ^listen
$unicorn_config > $unicorn_config_tmp
21 # the whole point of this exercise
22 echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
24 # allows ppid to be 1 in before_fork
25 echo "preload_app true" >> $unicorn_config_tmp
26 cat >> $unicorn_config_tmp <<\EOF
27 before_fork
do |server
,worker|
28 $master_ppid = Process.ppid
# should be zero to detect daemonization
32 mv $unicorn_config_tmp $unicorn_config
34 # rely on --daemonize switch, no & or -D
35 unicorn
-c $unicorn_config
39 t_begin
"hit with curl" && {
40 body
=$
(curl
-sSf http
://$listen/)
43 t_begin
"killing succeeds" && {
47 t_begin
"response body ppid == 1 (daemonized)" && {