Permalink
Browse files

improve unicorn/bluepill integration

  • Loading branch information...
1 parent baf0714 commit edbd25b8315c157945a0d2fde514ebd5bf70bb54 @dje dje committed Jun 13, 2011
Showing with 23 additions and 7 deletions.
  1. +1 −1 app/attributes/unicorn.rb
  2. +1 −1 app/metadata.rb
  3. +17 −1 app/recipes/bluepill.rb
  4. +1 −1 app/recipes/unicorn.rb
  5. +3 −3 app/templates/default/bluepill.erb
View
2 app/attributes/unicorn.rb
@@ -1,3 +1,3 @@
-default[:unicorn][:stand_alone] = true
+default[:unicorn][:bundled] = false
default[:unicorn][:timeout] = 30
default[:unicorn][:cow_friendly] = false
View
2 app/metadata.rb
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Installs/Configures a Rails app"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "0.1.0"
+version "0.1.1"
supports "ubuntu"
View
18 app/recipes/bluepill.rb
@@ -1,13 +1,29 @@
include_recipe "bluepill"
+if node[:unicorn][:bundled]
+ # Bundling unicorn with the app is the preferred method.
+ red_unicorn = "bundle exec red_unicorn"
+else
+ # Otherwise attempt to find gems bin path. This smells bad to me.
+ require "yaml"
+ path = ""
+ env = YAML::load(`gem environment`)["RubyGems Environment"]
+ env.each do |e|
+ path = e["EXECUTABLE DIRECTORY"] if e.key?("EXECUTABLE DIRECTORY")
+ end
+ red_unicorn = "red_unicorn --unicorn-exec #{path}/unicorn"
+end
+
template "/etc/bluepill/app.pill" do
source "bluepill.erb"
- variables( :environment => node[:app][:rails_env],
+ variables( :red_unicorn => red_unicorn,
+ :environment => node[:app][:rails_env],
:start_grace_time => node[:bluepill][:start_grace_time],
:stop_grace_time => node[:bluepill][:stop_grace_time],
:restart_grace_time => node[:bluepill][:restart_grace_time],
:mem_usage_mb => node[:bluepill][:mem_usage_mb],
:cpu_usage_percent => node[:bluepill][:cpu_usage_percent] )
+ notifies :load, "bluepill_service[app]"
end
bluepill_service "app" do
View
2 app/recipes/unicorn.rb
@@ -1,4 +1,4 @@
-gem_package "red_unicorn" if node[:unicorn][:stand_alone]
+gem_package "red_unicorn" unless node[:unicorn][:bundled]
directory "/etc/unicorn"
View
6 app/templates/default/bluepill.erb
@@ -3,9 +3,9 @@ Bluepill.application("app") do |app|
process.pid_file = "/var/run/unicorn/unicorn.pid"
process.working_dir = "/var/www/current"
- process.start_command = "red_unicorn --unicorn-exec /usr/local/bin/unicorn --env <%= @environment %> start"
- process.stop_command = "red_unicorn --unicorn-exec /usr/local/bin/unicorn stop"
- process.restart_command = "red_unicorn --unicorn-exec /usr/local/bin/unicorn restart"
+ process.start_command = "<%= @red_unicorn %> --env <%= @environment %> start"
+ process.stop_command = "<%= @red_unicorn %> stop"
+ process.restart_command = "<%= @red_unicorn %> restart"
process.uid = process.gid = "www-data"

0 comments on commit edbd25b

Please sign in to comment.