From 4b4ac5ed5d62cab76790661ba92a9ac4d5f1c105 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 25 Feb 2010 15:05:14 -0800 Subject: unicorn_rails: make this "working_directory"-aware The temporary paths we create to mimic script/server-emulation did not work when working_directory was used. Now we defer path creation until after working_directory is bound. --- bin/unicorn_rails | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/unicorn_rails b/bin/unicorn_rails index b327054..5204145 100755 --- a/bin/unicorn_rails +++ b/bin/unicorn_rails @@ -4,7 +4,6 @@ require 'unicorn/launcher' require 'optparse' require 'fileutils' -rails_pid = "#{Unicorn::HttpServer::START_CTX[:cwd]}/tmp/pids/unicorn.pid" cmd = File.basename($0) daemonize = false listeners = [] @@ -198,12 +197,12 @@ if $DEBUG end # ensure Rails standard tmp paths exist -%w(cache pids sessions sockets).each do |dir| - FileUtils.mkdir_p("tmp/#{dir}") +options[:after_reload] = lambda do + FileUtils.mkdir_p(%w(cache pids sessions sockets).map! { |d| "tmp/#{d}" }) end if daemonize - options[:pid] = rails_pid + options[:pid] = "tmp/pids/unicorn.pid" Unicorn::Launcher.daemonize!(options) end Unicorn.run(app, options) -- cgit v1.2.3-24-ge0c7