From 551789f8619b567333bbf41020323f4e1624841c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 4 Mar 2009 11:11:44 -0800 Subject: Remove "directory" config option Unicorn will always continue to run in the directory it started in, it does not chdir to "/". Since the default start_ctx[:cwd] is symlink-aware, this should not be a problem for Capistrano-deployed applications. --- bin/unicorn | 13 ++++--------- lib/unicorn.rb | 9 +-------- lib/unicorn/configurator.rb | 5 ----- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/bin/unicorn b/bin/unicorn index 3b467c9..d421f18 100755 --- a/bin/unicorn +++ b/bin/unicorn @@ -71,10 +71,6 @@ 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 @@ -174,11 +170,10 @@ if daemonize # 0000 and potentially exposing sensitive log data can be bad # policy. # * Don't bother to chdir here since Unicorn is designed to - # run inside APP_ROOT (or whatever the "directory" directive - # specifies). Unicorn will also re-chdir() to the directory - # it was started in when being re-executed to pickup code - # changes if the original deployment directory is a symlink - # or otherwise got replaced. + # run inside APP_ROOT. Unicorn will also re-chdir() to + # the directory it was started in when being re-executed + # to pickup code changes if the original deployment directory + # is a symlink or otherwise got replaced. end Unicorn.run(app, options) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 8754610..0727456 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -131,13 +131,6 @@ module Unicorn @pid = path end - # sets the path for running the master and worker process, useful for - # running and reexecuting from a symlinked path like Capistrano allows - def directory=(path) - Dir.chdir(path) if path - @directory = path - end - # add a given address to the +listeners+ set, idempotently # Allows workers to add a private, per-process listener via the # @after_fork hook. Very useful for debugging and testing. @@ -331,7 +324,7 @@ module Unicorn ENV.replace(@start_ctx[:environ]) ENV['UNICORN_FD'] = @listeners.map { |sock| sock.fileno }.join(',') File.umask(@start_ctx[:umask]) - Dir.chdir(@directory || @start_ctx[:cwd]) + Dir.chdir(@start_ctx[:cwd]) cmd = [ @start_ctx[:zero] ] + @start_ctx[:argv] logger.info "executing #{cmd.inspect} (in #{Dir.pwd})" exec(*cmd) diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 402204e..e01dbe1 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -28,7 +28,6 @@ module Unicorn :before_fork => lambda { |server, worker_nr| server.logger.info("worker=#{worker_nr} spawning...") }, - :directory => nil, :pid => nil, :backlog => 1024, :preload_app => false, @@ -142,10 +141,6 @@ module Unicorn # sets the +path+ for the PID file of the unicorn master process def pid(path); set_path(:pid, path); end - def directory(path) - @set[:directory] = path ? File.expand_path(path) : nil - end - def preload_app(bool) case bool when TrueClass, FalseClass -- cgit v1.2.3-24-ge0c7