From 334e37421ef4fcd9d70538c926c52b871897d419 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 3 Nov 2009 23:34:45 -0800 Subject: configurator: working_directory affects pid, std{err,out}_paths It makes more sense this way since users usually expect config file directives to be order-independent. --- lib/unicorn/configurator.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/unicorn/configurator.rb') diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 93b7bf4..6559e7c 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -94,6 +94,15 @@ module Unicorn def reload #:nodoc: instance_eval(File.read(config_file), config_file) if config_file + + # working_directory binds immediately (easier error checking that way), + # now ensure any paths we changed are correctly set. + [ :pid, :stderr_path, :stdout_path ].each do |var| + String === (path = set[var]) or next + path = File.expand_path(path) + test(?w, path) || test(?w, File.dirname(path)) or \ + raise ArgumentError, "directory for #{var}=#{path} not writable" + end end def commit!(server, options = {}) #:nodoc: @@ -385,15 +394,11 @@ module Unicorn def set_path(var, path) #:nodoc: case path - when NilClass - when String - path = File.expand_path(path) - File.writable?(File.dirname(path)) or \ - raise ArgumentError, "directory for #{var}=#{path} not writable" + when NilClass, String + set[var] = path else raise ArgumentError end - set[var] = path end def set_hook(var, my_proc, req_arity = 2) #:nodoc: -- cgit v1.2.3-24-ge0c7