Skip to content

Instantly share code, notes, and snippets.

@johnreilly
Created March 15, 2010 18:22
Show Gist options
  • Save johnreilly/333132 to your computer and use it in GitHub Desktop.
Save johnreilly/333132 to your computer and use it in GitHub Desktop.
#
# Cookbook Name:: delayed_job
# Recipe:: default
#
if ['solo', 'app', 'app_master'].include?(node[:instance_role])
run_for_app("your_app_name_here") do |app_name, data|
ey_cloud_report "delayed_job" do
message "setting up delayed_job on #{app_name}"
end
worker_name = "delayed_job"
# The symlink is created in /data/app_name/current/tmp/pids -> /data/app_name/shared/pids, but shared/pids doesn't seem to be?
directory "/data/#{app_name}/shared/pids" do
owner node[:owner_name]
group node[:owner_name]
mode 0755
end
template "/etc/monit.d/delayed_job_worker.#{app_name}.monitrc" do
source "delayed_job_worker.monitrc.erb"
owner "root"
group "root"
mode 0644
variables({
:app_name => app_name,
:user => node[:owner_name],
:worker_name => worker_name,
:framework_env => node[:environment][:framework_env]
})
end
bash "restart delayed_job" do
user "root"
code "monit restart delayed_job"
end
end
end
check process <%= @worker_name %>
with pidfile /data/<%= @app_name %>/shared/pids/<%= @worker_name %>.pid
start program = "/bin/su -c '/usr/bin/env RAILS_ENV=<%= @framework_env %> /data/<%= @app_name %>/current/script/delayed_job start' - <%= @user %>"
stop program = "/bin/su -c '/usr/bin/env RAILS_ENV=<%= @framework_env %> /data/<%= @app_name %>/current/script/delayed_job stop' - <%= @user %>"
group <%= @app_name %>_jobs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment