Permalink
Browse files

merge branch feature/allow-unicorn-to-be-given-an-environment

  • Loading branch information...
2 parents 4599399 + fbfb990 commit e8dab43a42c63943499d861f7e01234df7995a34 Kevin Bullock committed Mar 12, 2013
Showing with 7 additions and 2 deletions.
  1. +4 −0 README.txt
  2. +3 −2 lib/vlad/unicorn_common.rb
View
@@ -59,6 +59,10 @@ unicorn_rackup:: The location of the rackup file unicorn should load.
unicorn_use_sudo:: Whether to use sudo to run the 'unicorn' command on
the remote host. Probably necessary if you specify a
user and group in unicorn.rb.
+unicorn_env:: Environment to be given to unicorn (value for `-E`).
+ Default value is based on `vlad/rails`'s `rails_env`.
+ If `rails_env` is not defined, `production` is used as
+ default value.
For more on specific issues when deploying Rails applications, see
rails-configuration.txt[link:docs/rails-configuration_txt.html].
@@ -19,13 +19,13 @@ def self.signal(sig = '0')
def self.start(opts = '')
cmd = signal('HUP')
- cmd << %( || (#{unicorn_command} -D --config-file #{unicorn_config} #{opts}))
+ cmd << %( || (#{unicorn_command} -D -E "#{unicorn_env}" --config-file #{unicorn_config} #{opts}))
maybe_sudo cmd
end
def self.reload(opts = '')
cmd = signal('USR2')
- cmd << %( || (#{unicorn_command} -D --config-file #{unicorn_config} #{opts}))
+ cmd << %( || (#{unicorn_command} -D -E "#{unicorn_env}" --config-file #{unicorn_config} #{opts}))
maybe_sudo cmd
end
@@ -42,6 +42,7 @@ def self.stop
set(:unicorn_config) { "#{current_path}/config/unicorn.rb" }
set :unicorn_use_sudo, false
set(:unicorn_pid) { "#{shared_path}/pids/unicorn.pid" }
+ set(:unicorn_env) { begin rails_env ; rescue Rake::FetchError => e ; "production" end }
desc "Stop the app servers"
remote_task :stop_app, :roles => :app do

0 comments on commit e8dab43

Please sign in to comment.