Skip to content

Commit

Permalink
Import application version 0.99.11
Browse files Browse the repository at this point in the history
  • Loading branch information
schisamo committed Jun 1, 2011
1 parent d815301 commit bb35eec
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cookbooks/application/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"application::tomcat": "Sets up the deployed Java application with Tomcat as the servlet container",
"application::unicorn": "Sets up the deployed Rails application with Unicorn as the web server"
},
"version": "0.99.10"
"version": "0.99.11"
}
2 changes: 1 addition & 1 deletion cookbooks/application/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
license "Apache 2.0"
description "Deploys and configures a variety of applications defined from databag 'apps'"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.99.10"
version "0.99.11"
recipe "application", "Loads application databags and selects recipes to use"
recipe "application::django", "Deploys a Django application specified in a data bag with the deploy_revision resource"
recipe "application::gunicorn", "Sets up the deployed Django application with Gunicorn as the web server"
Expand Down
9 changes: 7 additions & 2 deletions cookbooks/application/recipes/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

app = node.run_state[:current_app]

# make the _default chef_environment look like the Rails production environment
rails_env = (node.chef_environment =~ /_default/ ? "production" : node.chef_environment)
node.run_state[:rails_env] = rails_env

###
# You really most likely don't want to run this recipe from here - let the
# default application recipe work it's mojo for you.
Expand Down Expand Up @@ -119,7 +123,8 @@
mode "644"
variables(
:host => dbm['fqdn'],
:databases => app['databases']
:databases => app['databases'],
:rails_env => rails_env
)
end
else
Expand Down Expand Up @@ -153,7 +158,7 @@
user app['owner']
group app['group']
deploy_to app['deploy_to']
environment 'RAILS_ENV' => node.chef_environment
environment 'RAILS_ENV' => rails_env
action app['force'][node.chef_environment] ? :force_deploy : :deploy
ssh_wrapper "#{app['deploy_to']}/deploy-ssh-wrapper" if app['deploy_key']
shallow_clone true
Expand Down
1 change: 1 addition & 0 deletions cookbooks/application/recipes/unicorn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
cookbook 'application'
options(
:app => app,
:rails_env => node.run_state[:rails_env] || node.chef_environment,
:smells_like_rack => ::File.exists?(::File.join(app['deploy_to'], "current", "config.ru"))
)
run_restart false
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/application/templates/default/database.yml.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%- @databases.each do |env, db| %>
<%= env %>:
<%= (env =~ /_default/ ? "production" : env) %>:
adapter: <%= db['adapter'] %>
host: <%= @host %>
database: <%= db['database'] %>
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/application/templates/default/sv-unicorn-run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
cd <%= @options[:app]['deploy_to'] %>/current

exec 2>&1
exec chpst -u <%= @options[:app]["owner"] %>:<%= @options[:app]["group"] %> <%= @options[:smells_like_rack] ? 'unicorn' : 'unicorn_rails' %> -E <%= node.chef_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 <%= @options[:rails_env] %> -c /etc/unicorn/<%= @options[:app]['id'] %>.rb

0 comments on commit bb35eec

Please sign in to comment.