Permalink
Browse files

make the _default chef_environment look like production rails env

  • Loading branch information...
1 parent 7857f50 commit fe114f52691b3fc34b7552a35f57065279b4dc6e @schisamo schisamo committed Jun 1, 2011
@@ -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.
@@ -119,7 +123,8 @@
mode "644"
variables(
:host => dbm['fqdn'],
- :databases => app['databases']
+ :databases => app['databases'],
+ :rails_env => rails_env
)
end
else
@@ -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
@@ -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
@@ -1,5 +1,5 @@
<%- @databases.each do |env, db| %>
-<%= env %>:
+<%= (env =~ /_default/ ? "production" : env) %>:
adapter: <%= db['adapter'] %>
host: <%= @host %>
database: <%= db['database'] %>
@@ -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 fe114f5

Please sign in to comment.