capistrano-sidekiq 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf404dc615e49f5dcacb9c604b35e4740e5f4535
4
+ data.tar.gz: 1f8f6105c214f25f0783f8e43f6f879e8ff8047b
5
+ SHA512:
6
+ metadata.gz: 3fe9ffb7062889b92fe95c06c4eee6eef1d7abc8b50ad1903567334f877edc9f480e45bc15c6258ba54345c63a5d3766d8f4d9702d98171d7b3e45b6b166c3f5
7
+ data.tar.gz: 2d5766260c45ef69c38f449b1343d0e52fbc2419912998edd443c16ff32e20ad3ba68b9ef5aaaf1c117851bd19bc166ab688be32963e6440476db75b82ce727e
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-sidekiq.gemspec
4
+ gemspec
@@ -0,0 +1,5 @@
1
+ Copyright (c) Abdelkader Boudih
2
+
3
+ capistrano-sidekiq is an Open Source project licensed under the terms of
4
+ the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
+ for license text.
@@ -0,0 +1,26 @@
1
+ # Capistrano::Sidekiq
2
+
3
+ Sidekiq integration for Capistrano
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-sidekiq' , github: 'seuros/capistrano-sidekiq'
10
+
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ ## Usage
17
+
18
+ TODO: Write usage instructions here
19
+
20
+ ## Contributing
21
+
22
+ 1. Fork it
23
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
24
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
25
+ 4. Push to the branch (`git push origin my-new-feature`)
26
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/sidekiq/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-sidekiq"
8
+ spec.version = Capistrano::Sidekiq::VERSION
9
+ spec.authors = ["Abdelkader Boudih"]
10
+ spec.email = ["terminale@gmail.com"]
11
+ spec.summary = %q{Sidekiq integration for Capistrano}
12
+ spec.description = %q{Sidekiq integration for Capistrano}
13
+ spec.homepage = 'https://github.com/seuros/capistrano-sidekiq'
14
+ spec.license = "LGPL-3.0"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'capistrano'
20
+ spec.add_dependency 'sidekiq'
21
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ if Gem::Version.new(Capistrano::VERSION).release >= Gem::Version.new('3.0.0')
2
+ load File.expand_path('../tasks/sidekiq.cap', __FILE__)
3
+ else
4
+ require_relative 'tasks/capistrano2'
5
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Sidekiq
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,54 @@
1
+ Capistrano::Configuration.instance.load do
2
+
3
+ _cset(:sidekiq_default_hooks) { true }
4
+ _cset(:sidekiq_cmd) { "#{fetch(:bundle_cmd, "bundle")} exec sidekiq" }
5
+ _cset(:sidekiqctl_cmd) { "#{fetch(:bundle_cmd, "bundle")} exec sidekiqctl" }
6
+ _cset(:sidekiq_timeout) { 10 }
7
+ _cset(:sidekiq_role) { :app }
8
+ _cset(:sidekiq_pid) { "#{current_path}/tmp/pids/sidekiq.pid" }
9
+ _cset(:sidekiq_processes) { 1 }
10
+
11
+ if fetch(:sidekiq_default_hooks)
12
+ before 'deploy:update_code', 'sidekiq:quiet'
13
+ after 'deploy:stop', 'sidekiq:stop'
14
+ after 'deploy:start', 'sidekiq:start'
15
+ before 'deploy:restart', 'sidekiq:restart'
16
+ end
17
+
18
+ namespace :sidekiq do
19
+ def for_each_process(&block)
20
+ fetch(:sidekiq_processes).times do |idx|
21
+ yield((idx == 0 ? "#{fetch(:sidekiq_pid)}" : "#{fetch(:sidekiq_pid)}-#{idx}"), idx)
22
+ end
23
+ end
24
+
25
+ desc 'Quiet sidekiq (stop accepting new work)'
26
+ task :quiet, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
27
+ for_each_process do |pid_file, idx|
28
+ run "if [ -d #{current_path} ] && [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then cd #{current_path} && #{fetch(:sidekiqctl_cmd)} quiet #{pid_file} ; else echo 'Sidekiq is not running'; fi"
29
+ end
30
+ end
31
+
32
+ desc 'Stop sidekiq'
33
+ task :stop, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
34
+ for_each_process do |pid_file, idx|
35
+ run "if [ -d #{current_path} ] && [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then cd #{current_path} && #{fetch(:sidekiqctl_cmd)} stop #{pid_file} #{fetch :sidekiq_timeout} ; else echo 'Sidekiq is not running'; fi"
36
+ end
37
+ end
38
+
39
+ desc 'Start sidekiq'
40
+ task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
41
+ rails_env = fetch(:rails_env, 'production')
42
+ for_each_process do |pid_file, idx|
43
+ run "cd #{current_path} ; nohup #{fetch(:sidekiq_cmd)} -e #{rails_env} -i #{idx} -P #{pid_file} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
44
+ end
45
+ end
46
+
47
+ desc 'Restart sidekiq'
48
+ task :restart, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
49
+ stop
50
+ start
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,92 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :sidekiq_default_hooks, -> { true }
4
+
5
+ set :sidekiq_pid, -> { File.join(shared_path, 'tmp', 'pids', 'sidekiq.pid') }
6
+ set :sidekiq_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
7
+ set :sidekiq_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }
8
+
9
+ # "-d -i INT -P PATH" are added automatically.
10
+ set :sidekiq_options, -> { "-e #{fetch(:sidekiq_env)} -L #{fetch(:sidekiq_log)}" }
11
+
12
+ set :sidekiq_timeout, -> { 10 }
13
+ set :sidekiq_role, -> { :app }
14
+ set :sidekiq_processes, -> { 1 }
15
+ # Rbenv and RVM integration
16
+ set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w{ sidekiq sidekiqctl })
17
+ set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w{ sidekiq sidekiqctl })
18
+ end
19
+
20
+ end
21
+
22
+ namespace :deploy do
23
+ before :starting, :check_sidekiq_hooks do
24
+ invoke 'sidekiq:add_default_hooks' if fetch(:sidekiq_default_hooks)
25
+ end
26
+ end
27
+
28
+ namespace :sidekiq do
29
+ def for_each_process(&block)
30
+ fetch(:sidekiq_processes).times do |idx|
31
+ yield((idx.zero? ? "#{fetch(:sidekiq_pid)}" : "#{fetch(:sidekiq_pid).gsub('.pid', "-#{idx}.pid")}"), idx)
32
+ end
33
+ end
34
+
35
+ task :add_default_hooks do
36
+ after 'deploy:starting', 'sidekiq:quiet'
37
+ after 'deploy:updated', 'sidekiq:stop'
38
+ after 'deploy:reverted', 'sidekiq:stop'
39
+ after 'deploy:published', 'sidekiq:start'
40
+ end
41
+
42
+ desc 'Quiet sidekiq (stop processing new tasks)'
43
+ task :quiet do
44
+ on roles fetch(:sidekiq_role) do
45
+ for_each_process do |pid_file, idx|
46
+ if test("[ -f #{pid_file} ]") and test("kill -0 $( cat #{pid_file} )")
47
+ within current_path do
48
+ execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ desc 'Stop sidekiq'
56
+ task :stop do
57
+ on roles fetch(:sidekiq_role) do
58
+ for_each_process do |pid_file, idx|
59
+ if test("[ -f #{pid_file} ]") and test("kill -0 $( cat #{pid_file} )")
60
+ within current_path do
61
+ execute :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ desc 'Start sidekiq'
69
+ task :start do
70
+ on roles fetch(:sidekiq_role) do
71
+ within current_path do
72
+ for_each_process do |pid_file, idx|
73
+ command = "-i #{idx} -P #{pid_file} #{fetch(:sidekiq_options)}"
74
+ if defined?(JRUBY_VERSION)
75
+ command = "#{command} >/dev/null 2>&1 &"
76
+ warn 'Since JRuby doesn\'t support Process.daemon, Sidekiq will be running without the -d flag.'
77
+ else
78
+ command = "-d #{command}"
79
+ end
80
+ execute :bundle, :exec, :sidekiq, command
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ desc 'Restart sidekiq'
87
+ task :restart do
88
+ invoke 'sidekiq:stop'
89
+ invoke 'sidekiq:start'
90
+ end
91
+
92
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-sidekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Abdelkader Boudih
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sidekiq
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Sidekiq integration for Capistrano
42
+ email:
43
+ - terminale@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - capistrano-sidekiq.gemspec
54
+ - lib/capistrano-sidekiq.rb
55
+ - lib/capistrano/sidekiq.rb
56
+ - lib/capistrano/sidekiq/version.rb
57
+ - lib/capistrano/tasks/capistrano2.rb
58
+ - lib/capistrano/tasks/sidekiq.cap
59
+ homepage: https://github.com/seuros/capistrano-sidekiq
60
+ licenses:
61
+ - LGPL-3.0
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Sidekiq integration for Capistrano
83
+ test_files: []
84
+ has_rdoc: