about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-02 14:42:04 -0800
committerEric Wong <normalperson@yhbt.net>2009-03-03 11:13:15 -0800
commit72d09ad565e0844a1429fbe8bc83930ed676f737 (patch)
tree15c4b5cf7d4b91d97eedc5ace12f1470a45b4203
parent571f38c6c9efd776b0704ddba35078c972289de6 (diff)
downloadunicorn-72d09ad565e0844a1429fbe8bc83930ed676f737.tar.gz
Using `/bin/sh -c pwd` here instead of Dir.pwd since
the pwd shell builtin is symlink-aware if ENV['PWD']
is correct (and it is when launched via Cap).

Also, correctly use @directory if it is set.
-rw-r--r--lib/unicorn.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 4e09b0c..90fd29d 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -27,7 +27,9 @@ module Unicorn
 
     DEFAULT_START_CTX = {
       :argv => ARGV.map { |arg| arg.dup },
-      :cwd => Dir.pwd,
+      # don't rely on Dir.pwd here since it's not symlink-aware, and
+      # symlink dirs are the default with Capistrano...
+      :cwd => `/bin/sh -c pwd`.chomp("\n"),
       :zero => $0.dup,
       :environ => {}.merge!(ENV),
       :umask => File.umask,
@@ -324,7 +326,7 @@ module Unicorn
         ENV.replace(@start_ctx[:environ])
         ENV['UNICORN_FD'] = @listeners.map { |sock| sock.fileno }.join(',')
         File.umask(@start_ctx[:umask])
-        Dir.chdir(@cwd || @start_ctx[:cwd])
+        Dir.chdir(@directory || @start_ctx[:cwd])
         cmd = [ @start_ctx[:zero] ] + @start_ctx[:argv]
         logger.info "executing #{cmd.inspect} (in #{Dir.pwd})"
         exec(*cmd)