diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-06-10 08:47:10 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-06-10 09:46:54 +0000 |
commit | 4accf4449390c649bce0b1c9d84314d65fd41f8e (patch) | |
tree | 524a01dc72bb030de496986d29cdbc8183ce4919 /t | |
parent | bff55e030fa3dcd4ac24ec481a67d6f327d67797 (diff) | |
download | unicorn-4accf4449390c649bce0b1c9d84314d65fd41f8e.tar.gz |
Since we added support for the "working_directory" parameter, it often became unclear where/when certain paths would be bound. There are some extremely nasty dependencies and ordering issues when doing this. It's all pretty fragile, but works for now and we even have a full integration test to keep it working. I plan on cleaning this up 2.x.x to be less offensive to look at (Rainbows! and Zbatery are a bit tied to this at the moment). Thanks to Pierre Baillet for reporting this. ref: http://mid.gmane.org/AANLkTimKb7JARr_69nfVrJLvMZH3Gvs1o_KwZFLKfuxy@mail.gmail.com
Diffstat (limited to 't')
-rwxr-xr-x | t/t0003-working_directory.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/t/t0003-working_directory.sh b/t/t0003-working_directory.sh new file mode 100755 index 0000000..3faa6c0 --- /dev/null +++ b/t/t0003-working_directory.sh @@ -0,0 +1,53 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 4 "config.ru inside alt working_directory" + +t_begin "setup and start" && { + unicorn_setup + rtmpfiles unicorn_config_tmp + rm -rf $t_pfx.app + mkdir $t_pfx.app + + port=$(expr $listen : '[^:]*:\([0-9]\+\)') + host=$(expr $listen : '\([^:]*\):[0-9]\+') + + cat > $t_pfx.app/config.ru <<EOF +#\--daemonize --host $host --port $port +use Rack::ContentLength +use Rack::ContentType, "text/plain" +run lambda { |env| [ 200, {}, [ "#{\$master_ppid}\\n" ] ] } +EOF + # we have --host/--port in config.ru instead + grep -v ^listen $unicorn_config > $unicorn_config_tmp + + # the whole point of this exercise + echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp + + # allows ppid to be 1 in before_fork + echo "preload_app true" >> $unicorn_config_tmp + cat >> $unicorn_config_tmp <<\EOF +before_fork do |server,worker| + $master_ppid = Process.ppid # should be zero to detect daemonization +end +EOF + + mv $unicorn_config_tmp $unicorn_config + + # rely on --daemonize switch, no & or -D + unicorn -c $unicorn_config + unicorn_wait_start +} + +t_begin "hit with curl" && { + body=$(curl -sSf http://$listen/) +} + +t_begin "killing succeeds" && { + kill $unicorn_pid +} + +t_begin "response body ppid == 1 (daemonized)" && { + test "$body" -eq 1 +} + +t_done |