mina-sidekiq-upstart 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3142e282119266a06790d3aee4b7b98a39b4f5c1f61d90b1a69516a4864066df
4
- data.tar.gz: e15ca89d1aac02ebd648a0a2f2b346c3e6d2aa4d6ff263adf1203531aa0037fa
3
+ metadata.gz: 9f659f95a644757914deb28248bf96d64d01999bb690211ecdd0c166098231d5
4
+ data.tar.gz: 7ee74d6b539c0459c2e41968758ad71f64c3c572763f0457b8b2467641a4dbc4
5
5
  SHA512:
6
- metadata.gz: 77d26f5cc4302f04d452d212c8c1076340e65b6e2375ad109cddfa7cab7d7b47eccbd5e9be2a9e9d8b03ccce9532ab7d687c6560ff9a2b269d9cd9ffc885b707
7
- data.tar.gz: d66c69e93770be26534e074015be13d14d7a47adfdc0c10a6b5c4eae74d7da40f4242270b655a580ee29d0c258556c31efd35572fae54d55fb54625cdeea65ed
6
+ metadata.gz: 4705c3e5a87dfcfa7a01f0d4896bb8ffd9deb6a94880e078b619ee7cc33bdb706b5661d6d395bdb8f566dee75d6e42794e5a46c80fb718dc87ff9e2b4b2c99e3
7
+ data.tar.gz: e45e0dc924e306feeaf5f4e6f6a943c22c5ecff0dbe4e02714e7bd609298b6a63b6b722ef6a42437df802b7c4d39a705b2c4174cc23d412b7a6535f66403061e
@@ -30,92 +30,105 @@ require 'mina/rails'
30
30
 
31
31
  # ### sidekiq
32
32
  # Sets the path to sidekiq.
33
- set_default :sidekiq, lambda { "#{bundle_bin} exec sidekiq" }
33
+ set :sidekiq, -> { "#{fetch(:bundle_bin)} exec sidekiq" }
34
34
 
35
35
  # ### sidekiqctl
36
36
  # Sets the path to sidekiqctl.
37
- set_default :sidekiqctl, lambda { "#{bundle_prefix} sidekiqctl" }
37
+ set :sidekiqctl, -> { "#{fetch(:bundle_bin)} exec sidekiqctl" }
38
38
 
39
39
  # ### sidekiq_timeout
40
40
  # Sets a upper limit of time a worker is allowed to finish, before it is killed.
41
- set_default :sidekiq_timeout, 10
41
+ set :sidekiq_timeout, 11
42
42
 
43
43
  # ### sidekiq_config
44
44
  # Sets the path to the configuration file of sidekiq
45
- set_default :sidekiq_config, lambda { "#{deploy_to}/#{current_path}/config/sidekiq.yml" }
45
+ set :sidekiq_config, -> { "#{fetch(:current_path)}/config/sidekiq.yml" }
46
+
47
+ set :sidekiq_configs, -> {
48
+ [
49
+ # "#{fetch(:current_path)}/config/sidekiq_1.yml",
50
+ # "#{fetch(:current_path)}/config/sidekiq_2.yml"
51
+ ]
52
+ }
46
53
 
47
54
  # ### sidekiq_log
48
55
  # Sets the path to the log file of sidekiq
49
56
  #
50
- # To disable logging set it to "/dev/null"
51
- set_default :sidekiq_log, lambda { "#{deploy_to}/#{current_path}/log/sidekiq.log" }
57
+ set :sidekiq_log, -> { "#{fetch(:current_path)}/log/sidekiq.log" }
52
58
 
53
59
  # ### sidekiq_pid
54
60
  # Sets the path to the pid file of a sidekiq worker
55
- set_default :sidekiq_pid, lambda { "#{deploy_to}/#{shared_path}/pids/sidekiq.pid" }
61
+ set :sidekiq_pid, -> { "#{fetch(:shared_path)}/pids/sidekiq.pid" }
56
62
 
57
63
  # ### sidekiq_processes
58
64
  # Sets the number of sidekiq processes launched
59
- set_default :sidekiq_processes, 1
65
+ set :sidekiq_processes, 1
60
66
 
61
67
  # ## Control Tasks
62
68
  namespace :sidekiq do
63
69
  def for_each_process(&block)
64
- sidekiq_processes.times do |idx|
70
+ fetch(:sidekiq_processes).times do |idx|
65
71
  pid_file = if idx == 0
66
- sidekiq_pid
72
+ fetch(:sidekiq_pid)
67
73
  else
68
- "#{sidekiq_pid}-#{idx}"
74
+ "#{fetch(:sidekiq_pid)}-#{idx}"
69
75
  end
70
76
  yield(pid_file, idx)
71
77
  end
72
78
  end
73
79
 
80
+
74
81
  # ### sidekiq:quiet
75
82
  desc "Quiet sidekiq (stop accepting new work)"
76
83
  task :quiet => :environment do
77
84
  queue %[echo "-----> Quiet sidekiq (stop accepting new work)"]
78
- for_each_process do |pid_file, idx|
79
- queue %{
80
- if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
81
- cd "#{deploy_to}/#{current_path}"
82
- #{echo_cmd %{#{sidekiqctl} quiet #{pid_file}} }
83
- else
84
- echo 'Skip quiet command (no pid file found)'
85
- fi
86
- }
85
+ in_path(fetch(:current_path)) do
86
+ for_each_process do |pid_file, idx|
87
+ command %{
88
+ if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
89
+ #{fetch(:sidekiqctl)} quiet #{pid_file}
90
+ else
91
+ echo 'Skip quiet command (no pid file found)'
92
+ fi
93
+ }.strip
94
+ end
87
95
  end
88
96
  end
89
97
 
98
+
90
99
  # ### sidekiq:stop
91
100
  desc "Stop sidekiq"
92
- task :stop => :environment do
93
- queue %[echo "-----> Stop sidekiq"]
94
- for_each_process do |pid_file, idx|
95
- queue %[
96
- if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
97
- cd "#{deploy_to}/#{current_path}"
98
- #{echo_cmd %[#{sidekiqctl} stop #{pid_file} #{sidekiq_timeout}]}
99
- else
100
- echo 'Skip stopping sidekiq (no pid file found)'
101
- fi
102
- ]
101
+ task :stop => :remote_environment do
102
+ comment 'Stop sidekiq'
103
+ in_path(fetch(:current_path)) do
104
+ for_each_process do |pid_file, idx|
105
+ command %{
106
+ if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
107
+ #{fetch(:sidekiqctl)} stop #{pid_file} #{fetch(:sidekiq_timeout)}
108
+ else
109
+ echo 'Skip stopping sidekiq (no pid file found)'
110
+ fi
111
+ }.strip
112
+ end
103
113
  end
104
114
  end
105
115
 
106
116
  # ### sidekiq:start
107
117
  desc "Start sidekiq"
108
- task :start => :environment do
109
- queue %[echo "-----> Start sidekiq"]
110
- for_each_process do |pid_file, idx|
111
- #queue %{
112
- # cd "#{deploy_to}/#{current_path}"
113
- # #{echo_cmd %[#{sidekiq} -d -e #{rails_env} -C #{sidekiq_config} -i #{idx} -P #{pid_file} -L #{sidekiq_log}] }
114
- #}
115
- queue %[sudo start sidekiq app=#{deploy_to}/#{current_path} index=0 ]
118
+ task :start => :remote_environment do
119
+ comment 'Start sidekiq'
120
+ in_path(fetch(:current_path)) do
121
+ for_each_process do |pid_file, idx|
122
+ #queue %{
123
+ # cd "#{deploy_to}/#{current_path}"
124
+ # #{echo_cmd %[#{sidekiq} -d -e #{rails_env} -C #{sidekiq_config} -i #{idx} -P #{pid_file} -L #{sidekiq_log}] }
125
+ #}
126
+ queue %[sudo start sidekiq app=#{fetch(:current_path)} index=0 ]
127
+ end
116
128
  end
117
129
  end
118
130
 
131
+
119
132
  # ### sidekiq:restart
120
133
  desc "Restart sidekiq"
121
134
  task :restart do
@@ -1,5 +1,5 @@
1
1
  module MinaSidekiqUpstart
2
2
  def self.version
3
- "0.0.1"
3
+ "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-sidekiq-upstart
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
  - Максим Столбухин