about summary refs log tree commit homepage
path: root/lib/unicorn/configurator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unicorn/configurator.rb')
-rw-r--r--lib/unicorn/configurator.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb
index a074fcf..1f0852a 100644
--- a/lib/unicorn/configurator.rb
+++ b/lib/unicorn/configurator.rb
@@ -9,6 +9,7 @@ module Unicorn
   #
   # Example (when used with the unicorn config file):
   #   worker_processes 4
+  #   working_directory "/path/to/deploy/app/current"
   #   listen '/tmp/my_app.sock', :backlog => 1
   #   listen 9292, :tcp_nopush => true
   #   timeout 10
@@ -345,6 +346,16 @@ module Unicorn
       set_path(:stdout_path, path)
     end
 
+    # sets the working directory for Unicorn.  This ensures USR2 will
+    # start a new instance of Unicorn in this directory.  This may be
+    # a symlink.  You should specify this directive near the top or
+    # your config file before any relative paths for other config
+    # directives (or avoid relative paths entirely).
+    def working_directory(path)
+      # just let chdir raise errors
+      Dir.chdir(HttpServer::START_CTX[:cwd] = path)
+    end
+
     # expands "unix:path/to/foo" to a socket relative to the current path
     # expands pathnames of sockets if relative to "~" or "~username"
     # expands "*:port and ":port" to "0.0.0.0:port"