Commits

Kevin Bullock committed ba9e4b7 Merge

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

  • Participants
  • Parent commits a6e7f78, c51fc8d

Comments (0)

Files changed (2)

 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].

File lib/vlad/unicorn_common.rb

 
     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
 
   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