capistrano-sidekiq 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf404dc615e49f5dcacb9c604b35e4740e5f4535
4
- data.tar.gz: 1f8f6105c214f25f0783f8e43f6f879e8ff8047b
3
+ metadata.gz: 5ad138283f25fb8e7f052e76ebe99b729b97b6fe
4
+ data.tar.gz: f9ac72309d9b3973170be0510fe23e44e355b3a7
5
5
  SHA512:
6
- metadata.gz: 3fe9ffb7062889b92fe95c06c4eee6eef1d7abc8b50ad1903567334f877edc9f480e45bc15c6258ba54345c63a5d3766d8f4d9702d98171d7b3e45b6b166c3f5
7
- data.tar.gz: 2d5766260c45ef69c38f449b1343d0e52fbc2419912998edd443c16ff32e20ad3ba68b9ef5aaaf1c117851bd19bc166ab688be32963e6440476db75b82ce727e
6
+ metadata.gz: f6b45f749f552181926bb83c1e43c4ce811cd922a55585f438725621255e2263a22be1bf666d60db14d08788094761cf09cd2ed5d078c39ada24b1675c9229e2
7
+ data.tar.gz: c4a9082ac21c841d0b1c0d9a83d831846542ea3bdb77587003ffc1fa8c5525a6194d2e86a71873d8d356fe99a1d41f586874cd212548417f4a90114c3d7b1411
data/README.md CHANGED
@@ -8,14 +8,38 @@ Add this line to your application's Gemfile:
8
8
 
9
9
  gem 'capistrano-sidekiq' , github: 'seuros/capistrano-sidekiq'
10
10
 
11
+ or:
12
+
13
+ gem 'capistrano-sidekiq'
11
14
 
12
15
  And then execute:
13
16
 
14
17
  $ bundle
15
18
 
19
+
16
20
  ## Usage
21
+ ```ruby
22
+ # Capfile
23
+
24
+ require 'capistrano/sidekiq'
25
+ ```
26
+
27
+
28
+ Configurable options, shown here with defaults:
29
+
30
+ ```ruby
31
+ :sidekiq_default_hooks => true
32
+ :sidekiq_pid => File.join(shared_path, 'tmp', 'pids', 'sidekiq.pid')
33
+ :sidekiq_env => fetch(:rack_env, fetch(:rails_env, fetch(:stage)))
34
+ :sidekiq_log => File.join(shared_path, 'log', 'sidekiq.log')
35
+ :sidekiq_options => "-e #{fetch(:sidekiq_env)} -L #{fetch(:sidekiq_log)}"
36
+ :sidekiq_timeout => 10
37
+ :sidekiq_role => :app
38
+ :sidekiq_processes => 1
39
+ :sidekiq_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiq" # Only for capistrano2.5
40
+ :sidekiqctl_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiqctl" # Only for capistrano2.5
41
+ ```
17
42
 
18
- TODO: Write usage instructions here
19
43
 
20
44
  ## Contributing
21
45
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Sidekiq
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -1,11 +1,18 @@
1
1
  Capistrano::Configuration.instance.load do
2
2
 
3
3
  _cset(:sidekiq_default_hooks) { true }
4
+
5
+ _cset(:sidekiq_pid) { File.join(shared_path, 'pids', 'sidekiq.pid') }
6
+ _cset(:sidekiq_env) { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
7
+ _cset(:sidekiq_log) { File.join(shared_path, 'log', 'sidekiq.log') }
8
+
9
+ _cset(:sidekiq_options) { nil }
10
+
4
11
  _cset(:sidekiq_cmd) { "#{fetch(:bundle_cmd, "bundle")} exec sidekiq" }
5
12
  _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" }
13
+
14
+ _cset(:sidekiq_timeout) { 10 }
15
+ _cset(:sidekiq_role) { :app }
9
16
  _cset(:sidekiq_processes) { 1 }
10
17
 
11
18
  if fetch(:sidekiq_default_hooks)
@@ -18,7 +25,12 @@ Capistrano::Configuration.instance.load do
18
25
  namespace :sidekiq do
19
26
  def for_each_process(&block)
20
27
  fetch(:sidekiq_processes).times do |idx|
21
- yield((idx == 0 ? "#{fetch(:sidekiq_pid)}" : "#{fetch(:sidekiq_pid)}-#{idx}"), idx)
28
+ pid_file = if idx.zero? && fetch(:sidekiq_processes) <= 1
29
+ fetch(:sidekiq_pid)
30
+ else
31
+ fetch(:sidekiq_pid).gsub(/\.pid$/, "-#{idx}.pid")
32
+ end
33
+ yield(pid_file, idx)
22
34
  end
23
35
  end
24
36
 
@@ -38,9 +50,22 @@ Capistrano::Configuration.instance.load do
38
50
 
39
51
  desc 'Start sidekiq'
40
52
  task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
41
- rails_env = fetch(:rails_env, 'production')
42
53
  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
54
+ args = []
55
+ args.push "--index #{idx}"
56
+ args.push "--pidfile #{pid_file}"
57
+ args.push "--environment #{fetch(:sidekiq_env)}"
58
+ args.push "--logfile #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log)
59
+ args.push fetch(:sidekiq_options)
60
+
61
+ if defined?(JRUBY_VERSION)
62
+ args.push ">/dev/null 2>&1 &"
63
+ logger.info 'Since JRuby doesn\'t support Process.daemon, Sidekiq will not be running as a daemon.'
64
+ else
65
+ args.push "--daemon"
66
+ end
67
+
68
+ run "cd #{current_path} ; #{fetch(:sidekiq_cmd)} #{args.compact.join(' ')} ", :pty => false
44
69
  end
45
70
  end
46
71
 
@@ -6,8 +6,7 @@ namespace :load do
6
6
  set :sidekiq_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
7
7
  set :sidekiq_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }
8
8
 
9
- # "-d -i INT -P PATH" are added automatically.
10
- set :sidekiq_options, -> { "-e #{fetch(:sidekiq_env)} -L #{fetch(:sidekiq_log)}" }
9
+ set :sidekiq_options, -> { nil }
11
10
 
12
11
  set :sidekiq_timeout, -> { 10 }
13
12
  set :sidekiq_role, -> { :app }
@@ -28,7 +27,12 @@ end
28
27
  namespace :sidekiq do
29
28
  def for_each_process(&block)
30
29
  fetch(:sidekiq_processes).times do |idx|
31
- yield((idx.zero? ? "#{fetch(:sidekiq_pid)}" : "#{fetch(:sidekiq_pid).gsub('.pid', "-#{idx}.pid")}"), idx)
30
+ pid_file = if idx.zero? && fetch(:sidekiq_processes) <= 1
31
+ fetch(:sidekiq_pid)
32
+ else
33
+ fetch(:sidekiq_pid).gsub(/\.pid$/, "-#{idx}.pid")
34
+ end
35
+ yield(pid_file, idx)
32
36
  end
33
37
  end
34
38
 
@@ -70,14 +74,21 @@ namespace :sidekiq do
70
74
  on roles fetch(:sidekiq_role) do
71
75
  within current_path do
72
76
  for_each_process do |pid_file, idx|
73
- command = "-i #{idx} -P #{pid_file} #{fetch(:sidekiq_options)}"
77
+ args = []
78
+ args.push "--index #{idx}"
79
+ args.push "--pidfile #{pid_file}"
80
+ args.push "--environment #{fetch(:sidekiq_env)}"
81
+ args.push "--logfile #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log)
82
+ args.push fetch(:sidekiq_options)
83
+
74
84
  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.'
85
+ args.push ">/dev/null 2>&1 &"
86
+ warn 'Since JRuby doesn\'t support Process.daemon, Sidekiq will not be running as a daemon.'
77
87
  else
78
- command = "-d #{command}"
88
+ args.push "--daemon"
79
89
  end
80
- execute :bundle, :exec, :sidekiq, command
90
+
91
+ execute :bundle, :exec, :sidekiq, args.compact.join(' ')
81
92
  end
82
93
  end
83
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano