From 72d09ad565e0844a1429fbe8bc83930ed676f737 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 2 Mar 2009 14:42:04 -0800 Subject: symlink-aware start_ctx[:cwd] 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. --- lib/unicorn.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') 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) -- cgit v1.2.3-24-ge0c7