ppool 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/curses_process_controller.rb +20 -17
- data/lib/process_pool.rb +11 -3
- data/lib/terminal_process_controller.rb +17 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d2548c9a28db03e3abdc552d6fc3432d58dc71a
|
4
|
+
data.tar.gz: 5813e7a4b5c948309d05ccd4981083f282cf633e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4b18fb2de4b750e3457fff0db63a0d6bb08b4d27ccc562a0e8ed366582711bb30a14863b3b7712f01f4310471222b3e94054a00a717e1a5c743129b7fbb70a3
|
7
|
+
data.tar.gz: 32706e46ae2dfdb5aee17d72dd05fa5eb9edba49e506327cda65ffd14c961ebf4f483881d6a33d4fa0771edba5bbfd088a4972ff3c4a69d5bab66c69b7a68c2d
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# MIT License
|
3
3
|
#
|
4
|
-
# Copyright (c) 2016 Paul Taylor
|
4
|
+
# Copyright (c) 2016, 2017 Paul Taylor
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -43,21 +43,23 @@ module PPool
|
|
43
43
|
|
44
44
|
@win.attron(Curses.color_pair(3)|Curses::A_BOLD) {
|
45
45
|
@win.setpos(2 , 5)
|
46
|
-
@win.addstr("Time
|
46
|
+
@win.addstr("Time #{time_running}")
|
47
47
|
@win.setpos(3 , 5)
|
48
|
-
@win.addstr("Size
|
48
|
+
@win.addstr("Size #{@size}")
|
49
49
|
@win.setpos(4 , 5)
|
50
|
-
@win.addstr("Running
|
50
|
+
@win.addstr("Running #{stats[:active_processes]}")
|
51
51
|
@win.setpos(5 , 5)
|
52
|
-
@win.addstr("Started
|
52
|
+
@win.addstr("Started #{stats[:processes_started]}")
|
53
53
|
@win.setpos(6 , 5)
|
54
|
-
@win.addstr("Ended
|
54
|
+
@win.addstr("Ended #{stats[:processes_ended]}")
|
55
55
|
@win.setpos(7 , 5)
|
56
|
-
@win.addstr("
|
56
|
+
@win.addstr("Avg Elapsed Time #{stats[:avg_elapsed_time]} (ms)")
|
57
57
|
@win.setpos(8 , 5)
|
58
|
-
@win.addstr("
|
58
|
+
@win.addstr("Errors #{stats[:errors]}")
|
59
59
|
@win.setpos(9 , 5)
|
60
|
-
@win.addstr("
|
60
|
+
@win.addstr("Logs #{@logdir}")
|
61
|
+
@win.setpos(10 , 5)
|
62
|
+
@win.addstr(" #{@msg}")
|
61
63
|
}
|
62
64
|
|
63
65
|
process_keys
|
@@ -106,14 +108,15 @@ module PPool
|
|
106
108
|
Curses.close_screen
|
107
109
|
|
108
110
|
puts ""
|
109
|
-
puts "Time
|
110
|
-
puts "Size
|
111
|
-
puts "Running
|
112
|
-
puts "Started
|
113
|
-
puts "Ended
|
114
|
-
puts "
|
115
|
-
puts "
|
116
|
-
puts "
|
111
|
+
puts "Time #{time_running}"
|
112
|
+
puts "Size #{@size}"
|
113
|
+
puts "Running #{@last_stats[:active_processes]}"
|
114
|
+
puts "Started #{@last_stats[:processes_started]}"
|
115
|
+
puts "Ended #{@last_stats[:processes_ended]}"
|
116
|
+
puts "Avg Elapsed Time #{@last_stats[:avg_elapsed_time]}"
|
117
|
+
puts "Errors #{@last_stats[:errors]}"
|
118
|
+
puts "Logs #{@logdir}"
|
119
|
+
puts " #{@msg}"
|
117
120
|
puts ""
|
118
121
|
|
119
122
|
exit(0)
|
data/lib/process_pool.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# MIT License
|
3
3
|
#
|
4
|
-
# Copyright (c) 2016 Paul Taylor
|
4
|
+
# Copyright (c) 2016, 2017 Paul Taylor
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -32,6 +32,9 @@ module PPool
|
|
32
32
|
@started_count = 0
|
33
33
|
@ended_count = 0
|
34
34
|
@errors = 0
|
35
|
+
@process_start_time = {}
|
36
|
+
@avg_elapsed_time = 0
|
37
|
+
@total_elapsed_time = 0
|
35
38
|
end
|
36
39
|
|
37
40
|
|
@@ -52,6 +55,7 @@ module PPool
|
|
52
55
|
@controller.run_process
|
53
56
|
end
|
54
57
|
|
58
|
+
@process_start_time[pid] = Time.now
|
55
59
|
|
56
60
|
@active_processes = @active_processes + 1
|
57
61
|
@controller.process_started(pid, @active_processes)
|
@@ -65,12 +69,15 @@ module PPool
|
|
65
69
|
begin
|
66
70
|
pidStatus = Process.wait2(-1, Process::WNOHANG)
|
67
71
|
if pidStatus != nil
|
68
|
-
|
72
|
+
endedPid = pidStatus[0]
|
73
|
+
@total_elapsed_time = @total_elapsed_time + (Time.now - @process_start_time.delete(endedPid)) * 1000
|
74
|
+
@controller.process_ended(endedPid, pidStatus[1].exitstatus)
|
69
75
|
@active_processes = @active_processes - 1
|
70
76
|
@ended_count = @ended_count + 1
|
71
77
|
if pidStatus[1].exitstatus != 0
|
72
78
|
@errors = @errors + 1
|
73
79
|
end
|
80
|
+
@avg_elapsed_time = (@total_elapsed_time / @ended_count).round()
|
74
81
|
else
|
75
82
|
doneWaiting = true
|
76
83
|
end
|
@@ -94,7 +101,8 @@ module PPool
|
|
94
101
|
:active_processes => @active_processes,
|
95
102
|
:processes_started => @started_count,
|
96
103
|
:processes_ended => @ended_count,
|
97
|
-
:errors => @errors
|
104
|
+
:errors => @errors,
|
105
|
+
:avg_elapsed_time => @avg_elapsed_time
|
98
106
|
})
|
99
107
|
end
|
100
108
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# MIT License
|
3
3
|
#
|
4
|
-
# Copyright (c) 2016 Paul Taylor
|
4
|
+
# Copyright (c) 2016, 2017 Paul Taylor
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -47,12 +47,12 @@ module PPool
|
|
47
47
|
if stats != @last_stats
|
48
48
|
if @count % 20 == 0
|
49
49
|
|
50
|
-
puts "
|
51
|
-
puts " Time | Size Active Started Ended Errors"
|
52
|
-
puts "
|
50
|
+
puts "----------------------------------------------------------"
|
51
|
+
puts " Time | Size Active Started Ended Errors Avg Elapsed"
|
52
|
+
puts "=========================================================="
|
53
53
|
|
54
54
|
end
|
55
|
-
puts(" %s | %4d %4d %4d %4d %4d\n" % [time_running, @size, stats[:active_processes], stats[:processes_started], stats[:processes_ended], stats[:errors]])
|
55
|
+
puts(" %s | %4d %4d %4d %4d %4d %4d\n" % [time_running, @size, stats[:active_processes], stats[:processes_started], stats[:processes_ended], stats[:errors], stats[:avg_elapsed_time]])
|
56
56
|
@last_stats = stats
|
57
57
|
@count = @count + 1
|
58
58
|
end
|
@@ -68,25 +68,33 @@ module PPool
|
|
68
68
|
|
69
69
|
def process_keys
|
70
70
|
|
71
|
-
|
71
|
+
c = read_ch
|
72
|
+
case c
|
72
73
|
when '+'
|
73
74
|
inc_size
|
74
75
|
@last_stats = {}
|
75
|
-
|
76
|
+
erase_input
|
76
77
|
when '-'
|
77
78
|
dec_size
|
78
79
|
@last_stats = {}
|
79
|
-
|
80
|
+
erase_input
|
81
|
+
when '0'..'9'
|
82
|
+
set_size(c.to_i)
|
83
|
+
erase_input
|
80
84
|
when 'q', 'Q'
|
81
85
|
finishing
|
82
86
|
@last_stats = {}
|
83
|
-
|
87
|
+
erase_input
|
84
88
|
when 'x', 'X'
|
85
89
|
terminate
|
86
90
|
end
|
87
91
|
|
88
92
|
end
|
89
93
|
|
94
|
+
def erase_input
|
95
|
+
puts "\r "
|
96
|
+
end
|
97
|
+
|
90
98
|
def read_ch
|
91
99
|
begin
|
92
100
|
system("stty raw")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Taylor
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.6.8
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Pool of processes running a single command
|