forked from rubber/rubber
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace :rubber do | ||
namespace :sidekiq do | ||
|
||
rubber.allow_optional_tasks(self) | ||
|
||
before "deploy", "rubber:sidekiq:quiet" | ||
after "deploy:stop", "rubber:sidekiq:stop" | ||
after "deploy:start", "rubber:sidekiq:start" | ||
after "deploy:restart", "rubber:sidekiq:restart" | ||
|
||
desc "Quiet sidekiq (stop accepting new work)" | ||
task :quiet, :roles => :sidekiq do | ||
rsudo "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then ./bin/sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi", :as => rubber_env.app_user | ||
end | ||
|
||
desc "Stop sidekiq" | ||
task :stop, :roles => :sidekiq do | ||
# Allow workers up to 60 seconds to finish their processing. | ||
rsudo "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then ./bin/sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid 60 ; fi", :as => rubber_env.app_user | ||
end | ||
|
||
desc "Start sidekiq" | ||
task :start, :roles => :sidekiq do | ||
rsudo "cd #{current_path} ; nohup ./bin/sidekiq -e #{Rubber.env} -C #{current_path}/config/sidekiq.yml -P #{current_path}/tmp/pids/sidekiq.pid >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false, :as => rubber_env.app_user | ||
sleep 45 # Give the workers some time to start up before moving on so monit doesn't try to start as well. | ||
end | ||
|
||
desc "Restart sidekiq" | ||
task :restart, :roles => :sidekiq do | ||
stop | ||
start | ||
end | ||
|
||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
templates/sidekiq/config/rubber/role/sidekiq/monit-sidekiq.conf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<% | ||
@path = '/etc/monit/monit.d/monit-sidekiq.conf' | ||
%> | ||
|
||
<% | ||
start_program = "/usr/bin/sudo -H -u #{rubber_env.app_user} /bin/bash -l -c 'cd #{Rubber.root} ; nohup ./bin/sidekiq -e #{Rubber.env} -C #{Rubber.root}/config/sidekiq.yml -P #{Rubber.root}/tmp/pids/sidekiq.pid >> #{Rubber.root}/log/sidekiq.log 2>&1 &'" | ||
stop_program = "/usr/bin/sudo -H -u #{rubber_env.app_user} /bin/bash -l -c 'cd #{Rubber.root} && if [ -f #{Rubber.root}/tmp/pids/sidekiq.pid ]; then ./bin/sidekiqctl stop #{Rubber.root}/tmp/pids/sidekiq.pid 60 ; fi'" | ||
%> | ||
|
||
check process sidekiq with pidfile <%= Rubber.root %>/tmp/pids/sidekiq.pid | ||
group selenium_grid_hub | ||
start program = "<%= start_program %>" | ||
stop program = "<%= stop_program %>" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
role_dependencies: | ||
background_worker: [sidekiq] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
append_to_file 'Gemfile', "gem 'sidekiq'\n" if Rubber::Util::is_bundler? | ||
append_to_file 'Gemfile', "gem 'slim'\n" if Rubber::Util::is_bundler? |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
description: The sidekiq background queue system | ||
dependent_templates: | ||
- redis |