From 89c786d64ddbe74905d37bc0d110771de5f79f49 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 5 Oct 2009 23:31:28 -0700 Subject: Document the START_CTX hash contents Modifying this can be useful for esoteric cases like switching entire Ruby installations or if the app was originally started in a no-longer-existent directory and we can't upgrade because we can't chdir to it. --- lib/unicorn.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index c5a0677..ddec8e9 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -53,6 +53,27 @@ module Unicorn # We populate this at startup so we can figure out how to reexecute # and upgrade the currently running instance of Unicorn + # This Hash is considered a stable interface and changing its contents + # will allow you to switch between different installations of Unicorn + # or even different installations of the same applications without + # downtime. Keys of this constant Hash are described as follows: + # + # * 0 - the path to the unicorn/unicorn_rails executable + # * :argv - a deep copy of the ARGV array the executable originally saw + # * :cwd - the working directory of the application, this is where + # you originally started Unicorn. + # + # The following example may be used in your Unicorn config file to + # change your working directory during a config reload (HUP) without + # upgrading or restarting: + # + # Dir.chdir(Unicorn::HttpServer::START_CTX[:cwd] = path) + # + # To change your unicorn executable to a different path without downtime, + # you can set the following in your Unicorn config file, HUP and then + # continue with the traditional USR2 + QUIT upgrade steps: + # + # Unicorn::HttpServer::START_CTX[0] = "/home/bofh/1.9.2/bin/unicorn" START_CTX = { :argv => ARGV.map { |arg| arg.dup }, # don't rely on Dir.pwd here since it's not symlink-aware, and -- cgit v1.2.3-24-ge0c7