Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Functioning sidekiq recipe

  • Loading branch information...
commit 7dd2c340cea687b7b1262fd602f20f6121e085fc 1 parent a27b450
@jimneath jimneath authored
View
7 cookbooks/sidekiq/attributes/default.rb
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
#
# Cookbook Name:: sidekiq
# Attrbutes:: default
@@ -25,8 +24,4 @@
# Verbose
:verbose => false
-})
-=======
-sidekiq_workers(1)
-sidekiq_utility_name('sidekiq')
->>>>>>> ec0a0fd3582b9d5d364f67ff40890c82baa71261
+})
View
6 cookbooks/sidekiq/templates/setup/sidekiq.erb → cookbooks/sidekiq/files/default/sidekiq
@@ -40,7 +40,7 @@ start ()
{
# check if process is already running
if [[ -f $pid_file ]]; then
- pid=$(cat ${pid_file})
+ pid=$(cat "${pid_file}")
if [[ -d /proc/$pid ]]; then
echo "${0} is already running (${pid})"
@@ -51,7 +51,7 @@ start ()
fi
# start sidekiq
- sidekiq -C ${conf_file} -e ${rails_env} -r ${app_root} -P ${pid_file} -L ${log_file} &
+ sidekiq -C "${conf_file}" -e "${rails_env}" -r "${app_root}" -P "${pid_file}" -L "${log_file}" &
exit $?
}
@@ -59,7 +59,7 @@ start ()
stop ()
{
# stop using sidekiqctl
- sidekiqctl stop ${pid_file}
+ sidekiqctl stop "${pid_file}"
exit $?
}
View
30 cookbooks/sidekiq/recipes/cleanup.rb
@@ -2,6 +2,11 @@
# Cookbook Name:: sidekiq
# Recipe:: cleanup
#
+
+# monit
+service "monit" do
+ supports :reload => true
+end
unless named_util_or_app_server?(node[:sidekiq][:utility_name])
# report to dashboard
@@ -9,20 +14,9 @@
message "Cleaning up sidekiq (if needed)"
end
- # monit
- service "monit" do
- supports :reload => true
- end
-
if is_app_server? || is_util?
# loop through applications
node[:applications].each do |app_name, _|
- # stop sidekiq
- execute "stop-sidekiq-for-#{app_name}" do
- command "monit stop all -g #{app_name}_sidekiq"
- only_if "test -f /etc/monit.d/sidekiq_#{app_name}.monitrc"
- end
-
# monit
file "/etc/monit.d/sidekiq_#{app_name}.monitrc" do
action :delete
@@ -36,10 +30,16 @@
end
end
end
- end
- # bin script
- file "/engineyard/bin/sidekiq" do
- action :delete
+ # bin script
+ file "/engineyard/bin/sidekiq" do
+ action :delete
+ end
+
+ # stop sidekiq
+ execute "kill-sidekiq" do
+ command "pkill -f sidekiq"
+ only_if "pgrep -f sidekiq"
+ end
end
end
View
59 cookbooks/sidekiq/recipes/default.rb
@@ -3,60 +3,5 @@
# Recipe:: default
#
-<<<<<<< HEAD
-require_recipe "sidekiq::setup"
-require_recipe "sidekiq::cleanup"
-=======
-# worker count
-worker_count = node[:sidekiq_workers].to_i
-
-# install on solo or utility if present
-on_solo_or_utility(node[:sidekiq_utility_name]) do
- # report to dashboard
- ey_cloud_report "sidekiq" do
- message "Setting up sidekiq"
- end
-
- # loop through applications
- applications.each do |app_name, data|
- # monit
- template "/etc/monit.d/sidekiq_#{app_name}.monitrc" do
- mode 0644
- source "sidekiq.monitrc.erb"
- variables({
- :num_workers => worker_count,
- :app_name => app_name,
- :rails_env => framework_env
- })
- notifies :run, resources(:execute => 'sidekiq-reload-monit')
- end
-
- # bin script
- template "/engineyard/bin/sidekiq" do
- mode 0755
- source "sidekiq.erb"
- notifies :run, resources(:execute => 'sidekiq-reload-monit')
- end
-
- # yml files
- worker_count.times do |count|
- template "/data/#{app_name}/shared/config/sidekiq_#{count}.yml" do
- owner node[:owner_name]
- group node[:owner_name]
- mode 0644
- source "sidekiq.yml.erb"
- variables({
- :require => "/data/#{app_name}/current"
- })
- notifies :run, resources(:execute => 'sidekiq-reload-monit')
- end
- end
-
- # reload monit
- execute "sidekiq-reload-monit" do
- command "monit reload && sleep 2 && monit restart all -g #{app_name}_sidekiq"
- action :nothing
- end
- end
-end
->>>>>>> ec0a0fd3582b9d5d364f67ff40890c82baa71261
+include_recipe "sidekiq::setup"
+include_recipe "sidekiq::cleanup"
View
8 cookbooks/sidekiq/recipes/setup.rb
@@ -10,9 +10,9 @@
end
# bin script
- template "/engineyard/bin/sidekiq" do
+ remote_file "/engineyard/bin/sidekiq" do
mode 0755
- source "sidekiq.erb"
+ source "sidekiq"
backup false
end
@@ -34,7 +34,7 @@
:workers => node[:sidekiq][:workers],
:rails_env => node[:environment][:framework_env]
})
- notifies :run, resources(:execute => "restart-sidekiq-for-#{app_name}"), :immediately
+ notifies :run, resources(:execute => "restart-sidekiq-for-#{app_name}")
end
# yml files
@@ -46,7 +46,7 @@
source "sidekiq.yml.erb"
backup false
variables(node[:sidekiq])
- notifies :run, resources(:execute => "restart-sidekiq-for-#{app_name}"), :immediately
+ notifies :run, resources(:execute => "restart-sidekiq-for-#{app_name}")
end
end
end
View
0  ...books/sidekiq/templates/setup/sidekiq.monitrc.erb → ...oks/sidekiq/templates/default/sidekiq.monitrc.erb
File renamed without changes
View
0  cookbooks/sidekiq/templates/setup/sidekiq.yml.erb → cookbooks/sidekiq/templates/default/sidekiq.yml.erb
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.