Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a sidekiq template.

  • Loading branch information...
commit 3058c93a63ed2f4f6b1a19a70b24b12f63cde411 1 parent 133aa3e
@nirvdrum nirvdrum authored
View
35 templates/sidekiq/config/rubber/deploy-sidekiq.rb
@@ -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
View
13 templates/sidekiq/config/rubber/role/sidekiq/monit-sidekiq.conf
@@ -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 %>"
View
2  templates/sidekiq/config/rubber/rubber-sidekiq.yml
@@ -0,0 +1,2 @@
+role_dependencies:
+ background_worker: [sidekiq]
View
2  templates/sidekiq/templates.rb
@@ -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?
View
3  templates/sidekiq/templates.yml
@@ -0,0 +1,3 @@
+description: The sidekiq background queue system
+dependent_templates:
+ - redis
Please sign in to comment.
Something went wrong with that request. Please try again.