sidekiq_status 1.0.2 → 1.0.3
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.
- data/.rvmrc +1 -1
- data/.travis.yml +11 -2
- data/Gemfile +3 -0
- data/README.md +5 -0
- data/lib/sidekiq_status/version.rb +1 -1
- data/lib/sidekiq_status/web.rb +44 -52
- data/sidekiq_status.gemspec +1 -1
- data/spec/integration/sidekiq_spec.rb +5 -10
- data/spec/spec_helper.rb +6 -0
- data/spec/worker_spec.rb +7 -12
- metadata +6 -6
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use 1.9.3-
|
1
|
+
rvm use 1.9.3-p392-perf@sidekiq_status --create
|
data/.travis.yml
CHANGED
@@ -4,5 +4,14 @@ rvm:
|
|
4
4
|
- 1.9.3
|
5
5
|
# - jruby-19mode # JRuby in 1.9 mode
|
6
6
|
# - rbx-19mode
|
7
|
-
|
8
|
-
|
7
|
+
env:
|
8
|
+
global:
|
9
|
+
- SHOW_SIDEKIQ=true
|
10
|
+
matrix:
|
11
|
+
- SIDEKIQ_VERSION="~>2.4.0"
|
12
|
+
- SIDEKIQ_VERSION="~>2.5.4"
|
13
|
+
- SIDEKIQ_VERSION="~>2.6.5"
|
14
|
+
- SIDEKIQ_VERSION="~>2.7.5"
|
15
|
+
- SIDEKIQ_VERSION="~>2.8.0"
|
16
|
+
- SIDEKIQ_VERSION="~>2.9.0"
|
17
|
+
script: bundle exec rake
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -146,6 +146,11 @@ and clean status containers.
|
|
146
146
|
|
147
147
|
## Changelog
|
148
148
|
|
149
|
+
### 1.0.3
|
150
|
+
|
151
|
+
* Include SidekiqStatus::Web app into Sidekiq::Web app unobtrusively (Peter Fern)
|
152
|
+
* sidekiq 2.8.0 and 2.9.0 support
|
153
|
+
|
149
154
|
### 1.0.2
|
150
155
|
|
151
156
|
* sidekiq 2.7.0 support
|
data/lib/sidekiq_status/web.rb
CHANGED
@@ -1,75 +1,67 @@
|
|
1
1
|
module SidekiqStatus
|
2
2
|
# Hook into *Sidekiq::Web* Sinatra app which adds a new "/statuses" page
|
3
3
|
module Web
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
# @param [Sidekiq::Web]
|
8
|
-
def self.
|
9
|
-
|
4
|
+
# Location of SidekiqStatus::Web view templates
|
5
|
+
VIEW_PATH = File.expand_path('../../../web/views', __FILE__)
|
6
|
+
|
7
|
+
# @param [Sidekiq::Web] app
|
8
|
+
def self.registered(app)
|
9
|
+
app.helpers do
|
10
10
|
# Calls the given block for every possible template file in views,
|
11
11
|
# named name.ext, where ext is registered on engine.
|
12
12
|
def find_template(views, name, engine, &block)
|
13
|
-
super(
|
13
|
+
super(VIEW_PATH, name, engine, &block)
|
14
14
|
super
|
15
15
|
end
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
# Sidekiq >= 2.5.0
|
20
|
-
tabs['Statuses'] = 'statuses'
|
21
|
-
when Array
|
22
|
-
# Sidekiq < 2.5.0
|
23
|
-
tabs << 'Statuses'
|
24
|
-
else
|
25
|
-
raise ScriptError, 'unexpected Sidekiq::Web.tabs format'
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
get '/statuses' do
|
30
|
-
@count = (params[:count] || 25).to_i
|
31
|
-
|
32
|
-
@current_page = (params[:page] || 1).to_i
|
33
|
-
@current_page = 1 unless @current_page > 0
|
18
|
+
app.get '/statuses' do
|
19
|
+
@count = (params[:count] || 25).to_i
|
34
20
|
|
35
|
-
|
21
|
+
@current_page = (params[:page] || 1).to_i
|
22
|
+
@current_page = 1 unless @current_page > 0
|
36
23
|
|
37
|
-
|
38
|
-
@statuses = SidekiqStatus::Container.statuses(pageidx * @count, (pageidx + 1) * @count)
|
24
|
+
@total_size = SidekiqStatus::Container.size
|
39
25
|
|
40
|
-
|
41
|
-
|
26
|
+
pageidx = @current_page - 1
|
27
|
+
@statuses = SidekiqStatus::Container.statuses(pageidx * @count, (pageidx + 1) * @count)
|
42
28
|
|
43
|
-
|
44
|
-
|
45
|
-
slim :status
|
46
|
-
end
|
47
|
-
|
48
|
-
get '/statuses/:jid/kill' do
|
49
|
-
SidekiqStatus::Container.load(params[:jid]).request_kill
|
50
|
-
redirect to(:statuses)
|
51
|
-
end
|
29
|
+
render(:slim, :statuses)
|
30
|
+
end
|
52
31
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
32
|
+
app.get '/statuses/:jid' do
|
33
|
+
@status = SidekiqStatus::Container.load(params[:jid])
|
34
|
+
render(:slim, :status)
|
35
|
+
end
|
57
36
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
37
|
+
app.get '/statuses/:jid/kill' do
|
38
|
+
SidekiqStatus::Container.load(params[:jid]).request_kill
|
39
|
+
redirect to(:statuses)
|
40
|
+
end
|
62
41
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
42
|
+
app.get '/statuses/delete/all' do
|
43
|
+
SidekiqStatus::Container.delete
|
44
|
+
redirect to(:statuses)
|
45
|
+
end
|
67
46
|
|
47
|
+
app.get '/statuses/delete/complete' do
|
48
|
+
SidekiqStatus::Container.delete('complete')
|
49
|
+
redirect to(:statuses)
|
50
|
+
end
|
68
51
|
|
52
|
+
app.get '/statuses/delete/finished' do
|
53
|
+
SidekiqStatus::Container.delete(SidekiqStatus::Container::FINISHED_STATUS_NAMES)
|
54
|
+
redirect to(:statuses)
|
69
55
|
end
|
70
56
|
end
|
71
57
|
end
|
72
58
|
end
|
73
59
|
|
74
|
-
require 'sidekiq/web'
|
75
|
-
Sidekiq::Web.
|
60
|
+
require 'sidekiq/web' unless defined?(Sidekiq::Web)
|
61
|
+
Sidekiq::Web.register(SidekiqStatus::Web)
|
62
|
+
if Sidekiq::Web.tabs.is_a?(Array)
|
63
|
+
# For sidekiq < 2.5
|
64
|
+
Sidekiq::Web.tabs << "statuses"
|
65
|
+
else
|
66
|
+
Sidekiq::Web.tabs["Statuses"] = "statuses"
|
67
|
+
end
|
data/sidekiq_status.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = SidekiqStatus::VERSION
|
17
17
|
|
18
|
-
gem.add_runtime_dependency("sidekiq", ">= 2.
|
18
|
+
gem.add_runtime_dependency("sidekiq", ">= 2.4", "<= 2.9")
|
19
19
|
|
20
20
|
gem.add_development_dependency("activesupport")
|
21
21
|
gem.add_development_dependency("rspec")
|
@@ -9,7 +9,8 @@ describe SidekiqStatus::Worker do
|
|
9
9
|
command,
|
10
10
|
:chdir => DUMMY_APP_ROOT,
|
11
11
|
:err => :out,
|
12
|
-
:out => log_to
|
12
|
+
:out => log_to,
|
13
|
+
:pgroup => true
|
13
14
|
)
|
14
15
|
end
|
15
16
|
|
@@ -19,14 +20,8 @@ describe SidekiqStatus::Worker do
|
|
19
20
|
begin
|
20
21
|
yield(pid)
|
21
22
|
ensure
|
22
|
-
Process.kill('
|
23
|
-
Process.wait(pid
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def wait(&block)
|
28
|
-
Timeout.timeout(15) do
|
29
|
-
sleep(0.5) while !block.call
|
23
|
+
Process.kill('TERM', -Process.getpgid(pid))
|
24
|
+
Process.wait(pid)
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
@@ -70,4 +65,4 @@ describe SidekiqStatus::Worker do
|
|
70
65
|
end
|
71
66
|
end
|
72
67
|
end
|
73
|
-
end
|
68
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/worker_spec.rb
CHANGED
@@ -120,7 +120,6 @@ describe Sidekiq::Worker do
|
|
120
120
|
jid = SomeWorker.perform_async(*args)
|
121
121
|
container = SidekiqStatus::Container.load(jid)
|
122
122
|
|
123
|
-
ready = false
|
124
123
|
lets_stop = false
|
125
124
|
|
126
125
|
worker.extend(Module.new do
|
@@ -128,17 +127,13 @@ describe Sidekiq::Worker do
|
|
128
127
|
self.total=(200)
|
129
128
|
self.at(50, "25% done")
|
130
129
|
self.payload = 'some payload'
|
131
|
-
|
132
|
-
sleep(0.01) unless lets_stop
|
130
|
+
wait{ lets_stop }
|
133
131
|
end
|
134
132
|
end)
|
135
133
|
|
136
134
|
worker_thread = Thread.new{ worker.perform(jid) }
|
137
135
|
checker_thread = Thread.new do
|
138
|
-
|
139
|
-
|
140
|
-
container.reload
|
141
|
-
container.status.should == 'working'
|
136
|
+
wait{ container.reload.working? }
|
142
137
|
container.at.should == 50
|
143
138
|
container.total.should == 200
|
144
139
|
container.message.should == '25% done'
|
@@ -147,13 +142,13 @@ describe Sidekiq::Worker do
|
|
147
142
|
lets_stop = true
|
148
143
|
end
|
149
144
|
|
150
|
-
worker_thread.join(
|
151
|
-
checker_thread.join(
|
145
|
+
worker_thread.join(15)
|
146
|
+
checker_thread.join(15)
|
147
|
+
|
148
|
+
wait{ container.reload.complete? }
|
152
149
|
|
153
|
-
container.reload
|
154
|
-
container.status.should == 'complete'
|
155
150
|
container.payload.should == 'some payload'
|
156
151
|
container.message.should be_nil
|
157
152
|
end
|
158
153
|
end
|
159
|
-
end
|
154
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02
|
12
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|
@@ -18,10 +18,10 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
21
|
+
version: '2.4'
|
22
22
|
- - <=
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '2.
|
24
|
+
version: '2.9'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,10 +29,10 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '2.
|
32
|
+
version: '2.4'
|
33
33
|
- - <=
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '2.
|
35
|
+
version: '2.9'
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activesupport
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|