Created
April 20, 2012 23:43
-
-
Save cwise/2432689 to your computer and use it in GitHub Desktop.
resque cookbook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: resque | |
# Recipe:: default | |
# | |
if ['solo', 'util'].include?(node[:instance_role]) | |
execute "install resque gem" do | |
command "gem install resque redis redis-namespace yajl-ruby -r" | |
not_if { "gem list | grep resque" } | |
end | |
worker_count = 1 | |
#TODO: we might want to selectively update the number of workers based on the application | |
node[:applications].each do |app, data| | |
template "/etc/monit.d/resque_#{app}.monitrc" do | |
owner 'root' | |
group 'root' | |
mode 0644 | |
source "monitrc.conf.erb" | |
variables({ | |
:num_workers => worker_count, | |
:app_name => app, | |
:rails_env => node[:environment][:framework_env] | |
}) | |
end | |
worker_count.times do |count| | |
template "/data/#{app}/shared/config/resque_#{count}.conf" do | |
owner node[:owner_name] | |
group node[:owner_name] | |
mode 0644 | |
source "resque_#{app}.conf.erb" | |
end | |
end | |
execute "ensure-resque-is-setup-with-monit" do | |
command %Q{ | |
monit reload | |
} | |
end | |
execute "restart-resque" do | |
command %Q{ | |
echo "sleep 20 && monit -g #{app}_resque restart all" | at now | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment