about summary refs log tree commit homepage
path: root/bin
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-02-23 16:10:02 -0800
committerEric Wong <normalperson@yhbt.net>2009-02-23 16:13:12 -0800
commitecbff236982f0ac94555171f86cee217929a978a (patch)
tree3a4969a40a78def0f827e597539544abb28c409f /bin
parent8f98c7d125e817d1175ba359375baddf28db4b7b (diff)
downloadunicorn-ecbff236982f0ac94555171f86cee217929a978a.tar.gz
This allows Unicorn to be constantly started in symlink
paths such as the ones Capistrano creates
(e.g. "/u/apps/$app/current")
Diffstat (limited to 'bin')
-rwxr-xr-xbin/unicorn8
1 files changed, 6 insertions, 2 deletions
diff --git a/bin/unicorn b/bin/unicorn
index f682311..dd4cc64 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -78,6 +78,10 @@ opts = OptionParser.new("", 24, '  ') do |opts|
     listeners << address
   end
 
+  opts.on("-C", "--directory PATH", "run in this directory") do |d|
+    options[:directory] = d
+  end
+
   opts.on("-c", "--config-file FILE", "Unicorn-specific config file") do |f|
     options[:config_file] = File.expand_path(f)
   end
@@ -159,11 +163,11 @@ if daemonize
     exit if fork
   end
 
-  Dir.chdir("/")
+  Dir.chdir("/") # setting options[:directory] will override this later on
   File.umask(0000)
   STDIN.reopen("/dev/null")
 
-  # we can redirect these again in the Unicorn after_fork hook
+  # we can redirect these again in the Unicorn {before,after}_fork hooks
   STDOUT.reopen("/dev/null", "a")
   STDERR.reopen("/dev/null", "a")
 end