Browse Source

[COOK-454] look for config.ru to determine if unicorn or unicorn_rails should be used

Seth Chisamore 13 years ago
parent
commit
1c5524c6a8
2 changed files with 5 additions and 2 deletions
  1. 4 1
      recipes/unicorn.rb
  2. 1 1
      templates/default/sv-unicorn-run.erb

+ 4 - 1
recipes/unicorn.rb

@@ -41,7 +41,10 @@ end
 runit_service app['id'] do
   template_name 'unicorn'
   cookbook 'application'
-  options(:app => app)
+  options(
+    :app => app,
+    :smells_like_rack => ::File.exists?(::File.join(app['deploy_to'], "current", "config.ru"))
+  )
   run_restart false
 end
 

+ 1 - 1
templates/default/sv-unicorn-run.erb

@@ -3,5 +3,5 @@
 cd <%= @options[:app]['deploy_to'] %>/current
 
 exec 2>&1
-exec chpst -u <%= @options[:app]["owner"] %>:<%= @options[:app]["group"] %> unicorn -E <%= node[:app_environment] %> -c /etc/unicorn/<%= @options[:app]['id'] %>.rb
+exec chpst -u <%= @options[:app]["owner"] %>:<%= @options[:app]["group"] %> <%= @options[:smells_like_rack] ? 'unicorn' : 'unicorn_rails' %> -E <%= node[:app_environment] %> -c /etc/unicorn/<%= @options[:app]['id'] %>.rb