Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create rails_new.rb #396

Open
wants to merge 1 commit into
base: release-chef-11.10
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions unicorn/recipes/rails_new.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
unless node[:opsworks][:skip_uninstall_of_other_rails_stack]
include_recipe "apache2::uninstall"
end

include_recipe "nginx"
include_recipe "unicorn"

# setup Unicorn service per app
node[:deploy].each do |application, deploy|
if deploy[:application_type] != 'rails'
Chef::Log.debug("Skipping unicorn::rails application #{application} as it is not an Rails app")
next
end

opsworks_deploy_user do
deploy_data deploy
end

opsworks_deploy_dir do
user deploy[:user]
group deploy[:group]
path deploy[:deploy_to]
end

template "#{deploy[:deploy_to]}/shared/scripts/unicorn" do
mode '0755'
owner deploy[:user]
group deploy[:group]
source "unicorn.service.erb"
variables(:deploy => deploy, :application => application)
end

service "unicorn_#{application}" do
start_command "#{deploy[:deploy_to]}/shared/scripts/unicorn start"
stop_command "#{deploy[:deploy_to]}/shared/scripts/unicorn stop"
restart_command "#{deploy[:deploy_to]}/shared/scripts/unicorn restart"
status_command "#{deploy[:deploy_to]}/shared/scripts/unicorn status"
action :nothing
end

template "#{deploy[:deploy_to]}/shared/config/unicorn.conf" do
mode '0644'
owner deploy[:user]
group deploy[:group]
source "unicorn.conf.erb"
variables(
:deploy => deploy,
:application => application,
:environment => OpsWorks::Escape.escape_double_quotes(deploy[:environment_variables])
)
end
end