From b2eddd6ec43b2bce0bfbfcc7fcaa731ac5844b44 Mon Sep 17 00:00:00 2001 From: Jan Szumiec Date: Fri, 12 Apr 2013 16:23:58 +0100 Subject: [PATCH] Support for custom unicorn config paths. --- README.md | 12 +++++++----- lib/capistrano-unicorn/capistrano_integration.rb | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f657c4a..7a5b7f4 100644 --- a/README.md +++ b/README.md @@ -59,11 +59,13 @@ cap unicorn:reload You can modify any of the following options in your `deploy.rb` config. -- `unicorn_env` - Set unicorn environment. Default to `rails_env` variable. -- `unicorn_pid` - Set unicorn PID file path. Default to `current_path/tmp/pids/unicorn.pid` -- `unicorn_bin` - Set unicorn executable file. Default to `unicorn`. -- `unicorn_bundle` - Set bundler command for unicorn. Default to `bundle`. -- `unicorn_user` - Launch unicorn master as the specified user. Default to `user` variable. +- `unicorn_env` - Set unicorn environment. Default to `rails_env` variable. +- `unicorn_pid` - Set unicorn PID file path. Default to `current_path/tmp/pids/unicorn.pid` +- `unicorn_bin` - Set unicorn executable file. Default to `unicorn`. +- `unicorn_bundle` - Set bundler command for unicorn. Default to `bundle`. +- `unicorn_user` - Launch unicorn master as the specified user. Default to `user` variable. +- `unicorn_config_path` - Set the directory where unicorn config files reside. Default to `current_path/config`. +- `unicorn_config_filename` - Set the filename of the unicorn config file. Not used in multistage installations. Default to `unicorn.rb`. ### Multistage diff --git a/lib/capistrano-unicorn/capistrano_integration.rb b/lib/capistrano-unicorn/capistrano_integration.rb index 04d93e2..eeff830 100644 --- a/lib/capistrano-unicorn/capistrano_integration.rb +++ b/lib/capistrano-unicorn/capistrano_integration.rb @@ -24,6 +24,8 @@ def self.load_into(capistrano_config) _cset(:unicorn_bundle) { fetch(:bundle_cmd) rescue 'bundle' } _cset(:unicorn_restart_sleep_time) { 2 } _cset(:unicorn_user) { nil } + _cset(:unicorn_config_path) { "#{fetch(:current_path)}/config" } + _cset(:unicorn_config_filename) { "unicorn.rb" } end # Check if a remote process exists using its pid file @@ -94,8 +96,8 @@ def kill_unicorn(signal) # Start the Unicorn server # def start_unicorn - primary_config_path = "#{current_path}/config/unicorn.rb" - secondary_config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb" + primary_config_path = "#{unicorn_config_path}/#{unicorn_config_filename}" + secondary_config_path = "#{unicorn_config_path}/unicorn/#{unicorn_env}.rb" script = <<-END set -x;