workerholic 0.0.16 → 0.0.17

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
  SHA1:
3
- metadata.gz: dfae6532e0efa5d65df17f7809ecc5130e50d85b
4
- data.tar.gz: b23e1f15e6ba5f1bc1494f98c01eefda76969bea
3
+ metadata.gz: 5697ecb058b0b8b66d692e0eba642dbf698396d9
4
+ data.tar.gz: eb530802994993ed86b5f46dcdb9bef99520e992
5
5
  SHA512:
6
- metadata.gz: 573cd2b6034209e578c3305ffdcec17a6a2da39d20f74b84e747a8a2a7e87b8f7ffc7c4158cdd5f3a39183069151af4bf5ddd7b5a96ec27ec782febdce0cedb1
7
- data.tar.gz: fb8a13ed3494db31e9177ddbddcac240121b3bd24ec603aa4f521bc8b676b6df49af99e3af87791a49bdb3619a4eaa3171b75edc7203925f7ff256e8b8263b1a
6
+ metadata.gz: 4aa98b63177bc19f3cbf4987d423e47cc90eee0d6d1e1151bc1c67023971741578f9d66910160f932ef96268a7bd5bf356b85b2fd91dd64e55106bf12ac51cf0
7
+ data.tar.gz: 9b8375989b80dc92c21a64e7db85df2450e8805efd81c35485a5aa546f7708c1d128e132cedf1b7e0edc0b9cc3e74acba9f1c8f013c3c40c4d463a6685df1f7c
data/bin/workerholic-web CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../web/application'
3
+ require_relative '../lib/workerholic/web/application'
4
4
 
5
5
  WorkerholicWeb.run!
6
-
@@ -16,7 +16,7 @@ module Workerholic
16
16
  job.statistics.completed_at = Time.now.to_f
17
17
 
18
18
  StatsStorage.save_job('completed_jobs', job)
19
- StatsStorage.update_historical_stats('completed_jobs', job.klass.name)
19
+ StatsStorage.update_historical_stats('completed_jobs', job.klass.to_s)
20
20
 
21
21
  # @logger.info("Completed: your job from class #{job.klass} was completed on #{job.statistics.completed_at}.")
22
22
  rescue Exception => e
@@ -1,3 +1,3 @@
1
1
  module Workerholic
2
- VERSION = '0.0.16'
2
+ VERSION = '0.0.17'
3
3
  end
@@ -1,14 +1,18 @@
1
- $LOAD_PATH << __dir__ + '/../lib'
1
+ $LOAD_PATH << __dir__ + '/../..'
2
2
  require 'sinatra/base'
3
3
 
4
- require 'sinatra/reloader'
4
+ # require 'sinatra/reloader'
5
5
  require 'json'
6
6
  require 'workerholic'
7
7
 
8
8
  class WorkerholicWeb < Sinatra::Base
9
9
 
10
10
  get '/' do
11
- redirect '/overview'
11
+ if defined? Rails
12
+ redirect '/workerholic/overview'
13
+ else
14
+ redirect '/overview'
15
+ end
12
16
  end
13
17
 
14
18
  get '/overview' do
@@ -60,6 +64,13 @@ class WorkerholicWeb < Sinatra::Base
60
64
  erb :history
61
65
  end
62
66
 
67
+ get '/overview-data-on-load' do
68
+ JSON.generate({
69
+ completed_jobs: Workerholic::StatsAPI.job_statistics_history('completed_jobs'),
70
+ failed_jobs: Workerholic::StatsAPI.job_statistics_history('failed_jobs')
71
+ })
72
+ end
73
+
63
74
  get '/overview-data' do
64
75
  JSON.generate({
65
76
  completed_jobs: Workerholic::StatsAPI.job_statistics( {category: 'completed_jobs', count_only: true} ),
@@ -68,6 +79,7 @@ class WorkerholicWeb < Sinatra::Base
68
79
  scheduled_jobs: Workerholic::StatsAPI.scheduled_jobs( { count_only: true }),
69
80
  workers_count: Workerholic.workers_count,
70
81
  memory_usage: Workerholic::StatsAPI.process_stats,
82
+ completed_jobs_per_second: Workerholic::StatsAPI.job_statistics_history('completed_jobs'),
71
83
  })
72
84
  end
73
85
 
@@ -5,8 +5,10 @@ var App = {
5
5
  jobsCompletedPerSecondHistory: [],
6
6
  totalMemoryHistory: [],
7
7
  maxTime: 240,
8
+ pollingInterval: 10,
9
+ chartFont: 'arial',
8
10
  freshDataCount: function() {
9
- return (this.maxTime / 5) + 1;
11
+ return (this.maxTime / (this.pollingInterval) ) + 1;
10
12
  },
11
13
  tab: null,
12
14
  removeStaleData: function() {
@@ -32,7 +34,7 @@ var App = {
32
34
  },
33
35
  getOverviewData: function() {
34
36
  $.ajax({
35
- url: '/overview-data',
37
+ url: 'overview-data',
36
38
  context: this,
37
39
  success: function(data) {
38
40
  var deserializedData = JSON.parse(data);
@@ -56,20 +58,21 @@ var App = {
56
58
  var memoryUsage = deserializedData.memory_usage;
57
59
  var totalMemoryUsage = 0;
58
60
 
61
+ $('.removable').remove();
62
+
59
63
  for (id in memoryUsage) {
60
64
  totalMemoryUsage = totalMemoryUsage + parseInt(memoryUsage[id]);
61
- if ($('#process_' + id).length === 1) {
62
- $('#process_' + id).text(parseInt(memoryUsage[id]) / 1000 + ' MB');
63
- } else {
64
- $('.nested').last().after("<tr class='nested'><td>" + id + "</td><td id='process_" + id + "''>" + memoryUsage[id] + "</td></tr>")
65
- }
65
+ $('.nested').last().after("<tr class='nested removable'><td>" + id + "</td><td id='process_" + id + "'" + "class='process_memory'" + ">" + memoryUsage[id] / 1000 + ' MB' + "</td></tr>")
66
66
  }
67
67
 
68
68
  this.queuedJobsCountHistory.unshift(queuedJobsCount);
69
69
  this.failedJobsCountHistory.unshift(failedJobsCount);
70
70
  this.jobsCompletedHistory.unshift(completedJobs);
71
71
  this.totalMemoryHistory.unshift(totalMemoryUsage / 1000);
72
- this.jobsCompletedPerSecondHistory.unshift((this.jobsCompletedHistory[0] - this.jobsCompletedHistory[1]) / 5 || 0);
72
+
73
+ for (var i = 0; i < this.freshDataCount(); i++) {
74
+ this.jobsCompletedPerSecondHistory[i] = (parseInt(deserializedData.completed_jobs_per_second[i]) / 10 || 0);
75
+ }
73
76
 
74
77
  this.removeStaleData();
75
78
  this.drawChart();
@@ -86,7 +89,7 @@ var App = {
86
89
  },
87
90
  getQueueData: function() {
88
91
  $.ajax({
89
- url: '/queues-data',
92
+ url: 'queues-data',
90
93
  success: function(data) {
91
94
  var deserializedData = JSON.parse(data);
92
95
  var queuedJobs = deserializedData.queued_jobs;
@@ -104,7 +107,7 @@ var App = {
104
107
  },
105
108
  getDetailData: function() {
106
109
  $.ajax({
107
- url: '/details-data',
110
+ url: 'details-data',
108
111
  success: function(data) {
109
112
  var deserializedData = JSON.parse(data);
110
113
  var completedJobs = deserializedData.completed_jobs;
@@ -143,7 +146,7 @@ var App = {
143
146
  });
144
147
 
145
148
  $.ajax({
146
- url: '/historic-data',
149
+ url: 'historic-data',
147
150
  data: {
148
151
  days: days,
149
152
  className: className,
@@ -154,6 +157,31 @@ var App = {
154
157
  }.bind(this)
155
158
  })
156
159
  },
160
+ getHistoricalOverviewData: function() {
161
+ $.ajax({
162
+ url: 'overview-data-on-load',
163
+ dataType: 'json',
164
+ success: function(data) {
165
+ for (var i = 0; i < this.freshDataCount(); i++) {
166
+ this.jobsCompletedPerSecondHistory[i] = (parseInt(data['completed_jobs'][i]) / 10 || 0);
167
+ }
168
+
169
+ for (var i = 0; i < this.freshDataCount(); i++) {
170
+ this.failedJobsCountHistory.push(parseInt(data['failed_jobs'][i]) || 0);
171
+ }
172
+
173
+ for (var i = 0; i < this.freshDataCount(); i++) {
174
+ this.queuedJobsCountHistory.push(0);
175
+ }
176
+
177
+ for (var i = 0; i < this.freshDataCount(); i++) {
178
+ this.totalMemoryHistory.push(0);
179
+ }
180
+
181
+ this.drawChart();
182
+ }.bind(this)
183
+ })
184
+ },
157
185
  drawChart: function() {
158
186
  var processedJobsChart = new CanvasJS.Chart('jobs_processed_container', {
159
187
  title: {
@@ -162,6 +190,8 @@ var App = {
162
190
  fontSize: 24,
163
191
  },
164
192
  axisX: {
193
+ labelFontFamily: this.chartFont,
194
+ titleFontFamily: this.chartFont,
165
195
  reversed: true,
166
196
  gridColor: 'Silver',
167
197
  tickColor: 'silver',
@@ -174,13 +204,15 @@ var App = {
174
204
  },
175
205
  theme: "theme2",
176
206
  axisY: {
207
+ labelFontFamily: this.chartFont,
208
+ titleFontFamily: this.chartFont,
177
209
  gridColor: "Silver",
178
210
  tickColor: "silver",
179
211
  title: 'Jobs per second',
180
212
  },
181
213
  data: [{
182
214
  type: "line",
183
- showInLegend: true,
215
+ showInLegend: false,
184
216
  name: "Jobs completed",
185
217
  color: "blue",
186
218
  markerType: 'circle',
@@ -196,6 +228,8 @@ var App = {
196
228
  fontSize: 24,
197
229
  },
198
230
  axisX: {
231
+ labelFontFamily: this.chartFont,
232
+ titleFontFamily: this.chartFont,
199
233
  reversed: true,
200
234
  gridColor: 'Silver',
201
235
  tickColor: 'silver',
@@ -209,13 +243,15 @@ var App = {
209
243
  },
210
244
  theme: "theme2",
211
245
  axisY: {
246
+ labelFontFamily: this.chartFont,
247
+ titleFontFamily: this.chartFont,
212
248
  gridColor: "Silver",
213
249
  tickColor: "silver",
214
250
  title: 'Jobs'
215
251
  },
216
252
  data: [{
217
253
  type: "line",
218
- showInLegend: true,
254
+ showInLegend: false,
219
255
  lineThickness: 6,
220
256
  name: "Queued Jobs",
221
257
  markerType: "circle",
@@ -231,6 +267,8 @@ var App = {
231
267
  fontSize: 24,
232
268
  },
233
269
  axisX: {
270
+ labelFontFamily: this.chartFont,
271
+ titleFontFamily: this.chartFont,
234
272
  reversed: true,
235
273
  gridColor: 'Silver',
236
274
  tickColor: 'silver',
@@ -244,13 +282,15 @@ var App = {
244
282
  },
245
283
  theme: "theme2",
246
284
  axisY: {
285
+ labelFontFamily: this.chartFont,
286
+ titleFontFamily: this.chartFont,
247
287
  gridColor: "Silver",
248
288
  tickColor: "silver",
249
289
  title: 'Jobs'
250
290
  },
251
291
  data: [{
252
292
  type: "line",
253
- showInLegend: true,
293
+ showInLegend: false,
254
294
  name: "Failed Jobs",
255
295
  color: "#20B2AA",
256
296
  markerType: 'circle',
@@ -267,6 +307,8 @@ var App = {
267
307
  fontSize: 24,
268
308
  },
269
309
  axisX: {
310
+ labelFontFamily: this.chartFont,
311
+ titleFontFamily: this.chartFont,
270
312
  reversed: true,
271
313
  gridColor: 'Silver',
272
314
  tickColor: 'silver',
@@ -280,13 +322,15 @@ var App = {
280
322
  },
281
323
  theme: "theme2",
282
324
  axisY: {
325
+ labelFontFamily: this.chartFont,
326
+ titleFontFamily: this.chartFont,
283
327
  gridColor: "Silver",
284
328
  tickColor: "silver",
285
329
  title: 'Memory (mb)'
286
330
  },
287
331
  data: [{
288
332
  type: "line",
289
- showInLegend: true,
333
+ showInLegend: false,
290
334
  name: "Memory usage",
291
335
  color: "#20B2AA",
292
336
  markerType: 'circle',
@@ -308,7 +352,8 @@ var App = {
308
352
  fontSize: 24,
309
353
  },
310
354
  axisX: {
311
- // reversed: true,
355
+ labelFontFamily: this.chartFont,
356
+ titleFontFamily: this.chartFont,
312
357
  gridColor: 'Silver',
313
358
  tickColor: 'silver',
314
359
  animationEnabled: true,
@@ -320,13 +365,15 @@ var App = {
320
365
  },
321
366
  theme: "theme2",
322
367
  axisY: {
368
+ labelFontFamily: this.chartFont,
369
+ titleFontFamily: this.chartFont,
323
370
  gridColor: "Silver",
324
371
  tickColor: "silver",
325
372
  title: 'Jobs'
326
373
  },
327
374
  data: [{
328
375
  type: "line",
329
- showInLegend: true,
376
+ showInLegend: false,
330
377
  name: "Completed Job for " + className,
331
378
  color: "#20B2AA",
332
379
  markerType: 'circle',
@@ -343,6 +390,8 @@ var App = {
343
390
  fontSize: 24,
344
391
  },
345
392
  axisX: {
393
+ labelFontFamily: this.chartFont,
394
+ titleFontFamily: this.chartFont,
346
395
  gridColor: 'Silver',
347
396
  tickColor: 'silver',
348
397
  animationEnabled: true,
@@ -354,13 +403,15 @@ var App = {
354
403
  },
355
404
  theme: "theme2",
356
405
  axisY: {
406
+ labelFontFamily: this.chartFont,
407
+ titleFontFamily: this.chartFont,
357
408
  gridColor: "Silver",
358
409
  tickColor: "silver",
359
410
  title: 'Jobs'
360
411
  },
361
412
  data: [{
362
413
  type: "line",
363
- showInLegend: true,
414
+ showInLegend: false,
364
415
  name: "Failed Jobs for " + className,
365
416
  color: "#20B2AA",
366
417
  markerType: 'circle',
@@ -388,7 +439,7 @@ var App = {
388
439
  var data = [];
389
440
 
390
441
  for (var i = 0; i <= count; i++) {
391
- var point = { x: (i * 5).toString(), y: array[i] };
442
+ var point = { x: (i * this.pollingInterval).toString(), y: array[i] };
392
443
  data.push(point);
393
444
  }
394
445
 
@@ -411,23 +462,24 @@ var App = {
411
462
  },
412
463
  pollData: function(tab) {
413
464
  if (tab === 'overview') {
465
+ this.getHistoricalOverviewData();
414
466
  this.getOverviewData();
415
467
 
416
468
  setInterval(function() {
417
469
  this.getOverviewData();
418
- }.bind(this), 5000);
470
+ }.bind(this), this.pollingInterval * 1000);
419
471
  }
420
472
 
421
473
  if (tab === 'queues') {
422
474
  setInterval(function() {
423
475
  this.getQueueData();
424
- }.bind(this), 5000);
476
+ }.bind(this), this.pollingInterval * 1000);
425
477
  }
426
478
 
427
479
  if (tab === 'details') {
428
480
  setInterval(function() {
429
481
  this.getDetailData();
430
- }.bind(this), 5000);
482
+ }.bind(this), this.pollingInterval * 1000);
431
483
  }
432
484
 
433
485
  if (tab === 'history') {
@@ -70,7 +70,6 @@ nav a:hover {
70
70
  }
71
71
 
72
72
  .nested th, .nested td {
73
- display: none;
74
73
  padding-left: 50px
75
74
  }
76
75
 
File without changes
File without changes
File without changes
File without changes
@@ -39,22 +39,22 @@
39
39
  <th>Memory Usage</th>
40
40
  </tr>
41
41
  <% @processes.each do |id, memory| %>
42
- <tr class='nested'>
42
+ <tr class='nested removable'>
43
43
  <td><%= id %></td>
44
- <td id='process_<%= id %>'></td>
44
+ <td id='process_<%= id %>' class='process_memory'></td>
45
45
  </tr>
46
46
  <% end %>
47
47
  </tbody>
48
48
  </table>
49
49
 
50
- <div id="queued_jobs_container" class="chart">
50
+ <div id="jobs_processed_container" class="chart">
51
51
  </div>
52
52
 
53
- <div id="failed_jobs_container" class="chart">
53
+ <div id="total_memory_container" class="chart">
54
54
  </div>
55
55
 
56
- <div id="jobs_processed_container" class="chart">
56
+ <div id="queued_jobs_container" class="chart">
57
57
  </div>
58
58
 
59
- <div id="total_memory_container" class="chart">
59
+ <div id="failed_jobs_container" class="chart">
60
60
  </div>
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workerholic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Leclercq
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-04 00:00:00.000000000 Z
13
+ date: 2017-08-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redis
@@ -141,6 +141,18 @@ files:
141
141
  - lib/workerholic/statistics_storage.rb
142
142
  - lib/workerholic/storage.rb
143
143
  - lib/workerholic/version.rb
144
+ - lib/workerholic/web/application.rb
145
+ - lib/workerholic/web/public/javascripts/application.js
146
+ - lib/workerholic/web/public/stylesheets/application.css
147
+ - lib/workerholic/web/public/stylesheets/whitespace-reset.css
148
+ - lib/workerholic/web/views/details.erb
149
+ - lib/workerholic/web/views/failed.erb
150
+ - lib/workerholic/web/views/history.erb
151
+ - lib/workerholic/web/views/layout.erb
152
+ - lib/workerholic/web/views/overview.erb
153
+ - lib/workerholic/web/views/queues.erb
154
+ - lib/workerholic/web/views/scheduled.erb
155
+ - lib/workerholic/web/views/workers.erb
144
156
  - lib/workerholic/worker.rb
145
157
  - lib/workerholic/worker_balancer.rb
146
158
  - pkg/workerholic-0.0.14.gem
@@ -163,18 +175,6 @@ files:
163
175
  - spec/storage_spec.rb
164
176
  - spec/worker_balancer_spec.rb
165
177
  - spec/worker_spec.rb
166
- - web/application.rb
167
- - web/public/javascripts/application.js
168
- - web/public/stylesheets/application.css
169
- - web/public/stylesheets/whitespace-reset.css
170
- - web/views/details.erb
171
- - web/views/failed.erb
172
- - web/views/history.erb
173
- - web/views/layout.erb
174
- - web/views/overview.erb
175
- - web/views/queues.erb
176
- - web/views/scheduled.erb
177
- - web/views/workers.erb
178
178
  - workerholic.gemspec
179
179
  homepage: https://github.com/workerholic/workerholic
180
180
  licenses: