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 +4 -4
- data/lib/mina_sidekiq_upstart/tasks.rb +52 -39
- data/lib/mina_sidekiq_upstart/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f659f95a644757914deb28248bf96d64d01999bb690211ecdd0c166098231d5
|
4
|
+
data.tar.gz: 7ee74d6b539c0459c2e41968758ad71f64c3c572763f0457b8b2467641a4dbc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
33
|
+
set :sidekiq, -> { "#{fetch(:bundle_bin)} exec sidekiq" }
|
34
34
|
|
35
35
|
# ### sidekiqctl
|
36
36
|
# Sets the path to sidekiqctl.
|
37
|
-
|
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
|
-
|
41
|
+
set :sidekiq_timeout, 11
|
42
42
|
|
43
43
|
# ### sidekiq_config
|
44
44
|
# Sets the path to the configuration file of sidekiq
|
45
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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 => :
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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 => :
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|