tiny_work_service 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_work_service.rb +13 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f03cbc2ef873707377dd8d5cc854cedfac5bc284e66a027cdb5fcd99f6c0797
|
4
|
+
data.tar.gz: 748a6d635f5680107a7b8f9afdcc46ca16db86a3e53db3dd6ce942e4894c9ad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62dd8cb1257265507eea8d6910d677528ae7e35917342c7733186a497393d8fbdbf7d53d1ee4daba02d6e016c40cff32383c7ae758f685084392ee14e336602d
|
7
|
+
data.tar.gz: 21e4c97697d3b1c28397ed3012e5f1c26f394771843bd98ff37fd5aa1454fc6a5813f12187376abe5f2b053685a117a6f3b04b7eda5da851c005938cf1f33a17
|
data/lib/tiny_work_service.rb
CHANGED
@@ -10,11 +10,12 @@ class TinyWorkService
|
|
10
10
|
:jobs_per_minute,
|
11
11
|
:jobs_per_hour
|
12
12
|
|
13
|
-
def initialize(port, label)
|
13
|
+
def initialize(port, label, refresh_interval_in_seconds)
|
14
14
|
@service = TinyTCPService.new(port)
|
15
15
|
@service.msg_handler = self
|
16
16
|
@jobs = Queue.new
|
17
17
|
@label = label
|
18
|
+
@label_and_port = "#{@label}:#{port}"
|
18
19
|
|
19
20
|
@jobs_enqueued = 0
|
20
21
|
@jobs_dequeued = 0
|
@@ -26,18 +27,22 @@ class TinyWorkService
|
|
26
27
|
|
27
28
|
# status printing thread
|
28
29
|
Thread.new do
|
30
|
+
start_time = Time.now
|
29
31
|
print "\e[?25l" # hide cursor
|
30
32
|
loop do
|
31
33
|
break unless @service.running?
|
34
|
+
sec_runtime = Time.now - start_time
|
35
|
+
human_runtime = "%02d:%02d:%02d" % [sec_runtime / 3600, sec_runtime / 60 % 60, sec_runtime % 60]
|
32
36
|
|
33
37
|
print "\e[1;1H"
|
34
|
-
puts "#{
|
35
|
-
puts "#{
|
36
|
-
puts "
|
37
|
-
puts "
|
38
|
-
puts "
|
39
|
-
|
40
|
-
|
38
|
+
puts "label/port: #{@label_and_port.rjust(28)}\e[K"
|
39
|
+
puts "time : #{DateTime.now.iso8601.rjust(28)}\e[K"
|
40
|
+
puts "runtime : #{human_runtime.rjust(28)}\e[K"
|
41
|
+
puts "workers : #{@service.num_clients.to_s.rjust(28)}\e[K"
|
42
|
+
puts "queue : #{@jobs.length.to_s.rjust(28)}\e[K"
|
43
|
+
puts "jobs/m : #{@jobs_per_minute.to_s.rjust(28)}\e[K"
|
44
|
+
print "jobs/h : #{@jobs_per_hour.to_s.rjust(28)}\e[K"
|
45
|
+
sleep refresh_interval_in_seconds
|
41
46
|
end
|
42
47
|
print "\e[?25h" # show cursor
|
43
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_work_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_tcp_service
|