Skip to content

Instantly share code, notes, and snippets.

@robdimarco
Forked from survival/default.rb
Created December 16, 2009 17:20
Show Gist options
  • Save robdimarco/257997 to your computer and use it in GitHub Desktop.
Save robdimarco/257997 to your computer and use it in GitHub Desktop.
#
# Cookbook Name:: delayed_job
# Recipe:: default
#
if ['solo', 'app', 'app_master'].include?(node[:instance_role])
# be sure to replace "app_name" with the name of your application.
run_for_app("maloca") do |app_name, data|
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 node[:owner_name]
#group node[:owner_name]
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 "monit-reload-restart" do
user "root"
code "pkill -9 monit && monit"
end
end
end
check process <%= @worker_name %>
with pidfile /data/<%= @app_name %>/shared/pids/<%= @worker_name %>.pid
start program = "/bin/su -c 'RAILS_ENV=<%= @framework_env %> /data/<%= @app_name %>/current/script/delayed_job start' - <%= @user %>"
stop program = "/bin/su -c '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