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

Improved recipe so that it uses default Opsworks definitions #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
40 changes: 1 addition & 39 deletions recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,4 @@

include_recipe "deploy"
include_recipe "opsworks_sidekiq::service"

node[:deploy].each do |application, deploy|
deploy = node[:deploy][application]

node.default[:deploy][application][:database][:adapter] = OpsWorks::RailsConfiguration.determine_database_adapter(application, node[:deploy][application], "#{node[:deploy][application][:deploy_to]}/current", :force => node[:force_database_adapter_detection])

template "#{deploy[:deploy_to]}/shared/config/database.yml" do
source "database.yml.erb"
cookbook 'rails'
mode "0660"
group deploy[:group]
owner deploy[:user]
variables(:database => deploy[:database], :environment => deploy[:rails_env])

notifies :run, resources(:execute => "restart Rails app #{application}")

only_if do
File.exists?(deploy[:deploy_to]) && File.exists?("#{deploy[:deploy_to]}/shared/config/")
end
end

template "#{deploy[:deploy_to]}/shared/config/memcached.yml" do
source "memcached.yml.erb"
cookbook 'rails'
mode "0660"
group deploy[:group]
owner deploy[:user]
variables(
:memcached => deploy[:memcached] || {},
:environment => deploy[:rails_env]
)

notifies :run, resources(:execute => "restart Rails app #{application}")

only_if do
File.exists?(deploy[:deploy_to]) && File.exists?("#{deploy[:deploy_to]}/shared/config/")
end
end
end
include_recipe "rails::configure"
23 changes: 13 additions & 10 deletions recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@
path deploy[:deploy_to]
end

include_recipe "opsworks_sidekiq::setup"
Chef::Log.debug("Running opsworks_sidekiq::setup for application #{application}")
node.set[:opsworks][:rails_stack][:recipe] = "opsworks_sidekiq::setup"
node.set[:opsworks][:rails_stack][:restart_command] = node[:sidekiq][application][:restart_command]

template "#{deploy[:deploy_to]}/shared/config/memcached.yml" do
cookbook "rails"
source "memcached.yml.erb"
mode 0660
owner deploy[:user]
group deploy[:group]
variables(:memcached => (deploy[:memcached] || {}), :environment => deploy[:rails_env])
opsworks_rails do
deploy_data deploy
app application
end

node.set[:opsworks][:rails_stack][:restart_command] = node[:sidekiq][application][:restart_command]

Chef::Log.debug("Deploying Sidekiq Application: #{application}")
opsworks_deploy do
deploy_data deploy
app application
end

Chef::Log.debug("Restarting Sidekiq Application: #{application}")
execute "restart Rails app #{application}" do
command node[:sidekiq][application][:restart_command]
end

end
2 changes: 1 addition & 1 deletion recipes/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Overwrite the unicorn restart command declared elsewhere
# Apologies for the `sleep`, but monit errors with "Other action already in progress" on some boots.
execute "restart Rails app #{application}" do
command "sleep 300 && #{node[:sidekiq][application][:restart_command]}"
command "sleep 60 && #{node[:sidekiq][application][:restart_command]}"
action :nothing
end

Expand Down