diff --git a/lib/capistrano3/tasks/unicorn.rake b/lib/capistrano3/tasks/unicorn.rake index 8003528..25d0823 100644 --- a/lib/capistrano3/tasks/unicorn.rake +++ b/lib/capistrano3/tasks/unicorn.rake @@ -1,11 +1,13 @@ namespace :load do task :defaults do - set :unicorn_pid, -> { File.join(current_path, "tmp", "pids", "unicorn.pid") } + set :unicorn_command, -> { [:bundle, :exec, :unicorn] } + set :unicorn_pid, -> { current_path.join('tmp', 'pids', 'unicorn.pid') } set :unicorn_config_path, -> do - if File.exist?(File.join(current_path, "config", "unicorn", "#{fetch(:rails_env)}.rb")) - File.join(current_path, "config", "unicorn", "#{fetch(:rails_env)}.rb") + unicorn_env_path = current_path.join('config', 'unicorn', "#{fetch(:rails_env)}.rb") + if File.exist?(unicorn_env_path) + unicorn_env_path else - File.join(current_path, "config", "unicorn.rb") + current_path.join('config', 'unicorn', "unicorn.rb") end end set :unicorn_roles, -> { :app } @@ -24,7 +26,7 @@ namespace :unicorn do info "unicorn is running..." else with rails_env: fetch(:rails_env) do - execute :bundle, "exec unicorn", "-c", fetch(:unicorn_config_path), "-E", fetch(:unicorn_rack_env), "-D", fetch(:unicorn_options) + execute *fetch(:unicorn_command), '-c', fetch(:unicorn_config_path), '-E', fetch(:unicorn_rack_env), '-D', fetch(:unicorn_options) end end end