Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@survival
Created September 19, 2009 06:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save survival/189423 to your computer and use it in GitHub Desktop.
Save survival/189423 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 '/data/<%= @app_name %>/current/script/delayed_job -e <%= @framework_env %> start' - <%= @user %>"
stop program = "/bin/su -c '/data/<%= @app_name %>/current/script/delayed_job -e <%= @framework_env %> stop' - <%= @user %>"
group <%= @app_name %>_jobs
@tispratik
Copy link

Thanks for sharing. Can you tell me how do you run this recipe? And how does the monitrc erb file get the values of all the @ variables?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment