Created
September 20, 2010 10:51
-
-
Save nileshbetter/587727 to your computer and use it in GitHub Desktop.
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]) | |
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