Skip to content

Instantly share code, notes, and snippets.

@nileshbetter
Created September 20, 2010 10:51
Show Gist options
  • Save nileshbetter/587727 to your computer and use it in GitHub Desktop.
Save nileshbetter/587727 to your computer and use it in GitHub Desktop.
# Cookbook Name:: resque
# Recipe:: default
#
#if ['solo', 'util'].include?(node[:instance_role])
if ['solo', 'app_master', 'app', '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
case node[:ec2][:instance_type]
when 'm1.small': worker_count = 2
when 'c1.medium': worker_count = 3
when 'c1.xlarge': worker_count = 8
else
worker_count = 4
end
# node[:applications].each do |app, data|
# template "/data/#{app}/shared/config/resque.yml" do
# owner node[:owner_name]
# group node[:owner_name]
# mode 0644
# source "resque.yml.erb"
#variables({
# :redis_hostname => node[:db_host]
# })
node[:applications].each do |app, data|
template "/data/#{app}/shared/config/resque.yml" do
owner node[:owner_name]
group node[:owner_name]
mode 0644
source "resque.yml.erb"
variables({
:redis_hostname => node[:db_host],
:rails_env => node[:environment][:framework_env]
})
end
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_wildcard.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