ppool 1.0.0 → 1.1.0
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/bin/ppool +32 -4
- data/lib/basic_process_controller.rb +24 -0
- data/lib/curses_process_controller.rb +27 -7
- data/lib/ppool.rb +23 -0
- data/lib/process_pool.rb +23 -0
- data/lib/shell_process_controller.rb +50 -1
- data/lib/terminal_process_controller.rb +27 -7
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c44a544f926a9563eb3d498c8a194676863919d5
|
4
|
+
data.tar.gz: f8977e5444cc2df43c0df2ff5712edfed61c8bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea14c6efa27b98e2a9ae5f83565d71950b13b5587ef430e345b4c83631af2f44f1133b4f6443b1a5893321fb4d0d44c9f180a2886f9c76d21812982874e191b7
|
7
|
+
data.tar.gz: 15ab0325e16cf79ce093f604f55fc6515b4e8d5b7776c27916ed413ab61bd560794dc3f02abfa8efc9801fc2509f93547f1c6cad07a3044d33cef2556fd8290a
|
data/bin/ppool
CHANGED
@@ -1,4 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2016 Paul Taylor
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
#
|
2
25
|
|
3
26
|
require 'rubygems'
|
4
27
|
require 'ppool'
|
@@ -6,9 +29,11 @@ require 'optparse'
|
|
6
29
|
|
7
30
|
|
8
31
|
options = {
|
9
|
-
:logdir => "./logs",
|
10
32
|
:size => 1,
|
33
|
+
:delay => 100,
|
11
34
|
:basic => false,
|
35
|
+
:logdir => "./ppool-logs",
|
36
|
+
:rmlogs => false
|
12
37
|
}
|
13
38
|
|
14
39
|
$USAGE = "Usage: ppool [options] COMMAND ARGS..."
|
@@ -17,9 +42,11 @@ $USAGE = "Usage: ppool [options] COMMAND ARGS..."
|
|
17
42
|
OptionParser.new do |opts|
|
18
43
|
opts.banner = $USAGE
|
19
44
|
|
20
|
-
opts.on('-l', '--logs DIR', 'Log directory') { |v| options[:logdir] = v }
|
21
45
|
opts.on('-s', '--size SIZE', 'Initial pool size') { |v| options[:size] = v }
|
46
|
+
opts.on('-d', '--delay MSECS', 'The delay between checking the state of the process pool (default 100ms)') { |v| options[:delay] = v }
|
22
47
|
opts.on('-b', '--basic', 'Basic (non curses) verion') { |v| options[:basic] = true}
|
48
|
+
opts.on('-r', '--rmlogs', 'Remove logs for processes that exited successfully') { |v| options[:rmlogs] = true}
|
49
|
+
opts.on('-l', '--logdir DIR', 'Log directory') { |v| options[:logdir] = v }
|
23
50
|
|
24
51
|
opts.on("-h", "--help", "Show this message") {
|
25
52
|
puts opts
|
@@ -40,11 +67,12 @@ if ! Dir.exist?(logdir)
|
|
40
67
|
end
|
41
68
|
|
42
69
|
size = options[:size].to_i
|
70
|
+
delay = options[:delay].to_i
|
43
71
|
|
44
72
|
if options[:basic]
|
45
|
-
controller = TerminalProcessController.new(size, command, logdir)
|
73
|
+
controller = TerminalProcessController.new(size, delay, command, logdir, options[:rmlogs])
|
46
74
|
else
|
47
|
-
controller = CursesProcessController.new(size, command, logdir)
|
75
|
+
controller = CursesProcessController.new(size, delay, command, logdir, options[:rmlogs])
|
48
76
|
end
|
49
77
|
|
50
78
|
ProcessPool.new(controller).run
|
@@ -1,3 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Paul Taylor
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
24
|
+
|
1
25
|
class BasicProcessController
|
2
26
|
|
3
27
|
def initialize
|
@@ -1,13 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Paul Taylor
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
1
24
|
|
2
25
|
require 'curses'
|
3
26
|
|
4
27
|
class CursesProcessController < ShellProcessController
|
5
28
|
|
6
|
-
def initialize(size, script, logdir)
|
7
|
-
super(script, logdir)
|
29
|
+
def initialize(size, delay, script, logdir, rmlogs)
|
30
|
+
super(script, logdir, rmlogs)
|
8
31
|
@finishing = false
|
9
32
|
@finished = false
|
10
33
|
@size = size
|
34
|
+
@delay = delay
|
11
35
|
@msg = ""
|
12
36
|
@last_stats = {}
|
13
37
|
init_window
|
@@ -25,9 +49,6 @@ class CursesProcessController < ShellProcessController
|
|
25
49
|
def process_started(pid, num_processes)
|
26
50
|
end
|
27
51
|
|
28
|
-
def process_ended(pid, status)
|
29
|
-
#draw_window
|
30
|
-
end
|
31
52
|
|
32
53
|
def progress(stats)
|
33
54
|
|
@@ -57,7 +78,6 @@ class CursesProcessController < ShellProcessController
|
|
57
78
|
process_keys
|
58
79
|
|
59
80
|
if @finishing
|
60
|
-
info "finishing #{stats[:active_processes]}"
|
61
81
|
if stats[:active_processes] == 0
|
62
82
|
@finished = true
|
63
83
|
end
|
@@ -67,7 +87,7 @@ class CursesProcessController < ShellProcessController
|
|
67
87
|
end
|
68
88
|
|
69
89
|
def delay
|
70
|
-
return
|
90
|
+
return @delay / 1000
|
71
91
|
end
|
72
92
|
|
73
93
|
|
data/lib/ppool.rb
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Paul Taylor
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
1
24
|
|
2
25
|
require "process_pool.rb"
|
3
26
|
require "basic_process_controller.rb"
|
data/lib/process_pool.rb
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Paul Taylor
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
1
24
|
|
2
25
|
class ProcessPool
|
3
26
|
|
@@ -1,10 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Paul Taylor
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
24
|
+
|
1
25
|
class ShellProcessController < BasicProcessController
|
2
26
|
|
3
|
-
def initialize(script, logdir)
|
27
|
+
def initialize(script, logdir, rmlogs)
|
4
28
|
super()
|
5
29
|
@script = script
|
6
30
|
@logdir = logdir
|
31
|
+
@rmlogs = rmlogs
|
7
32
|
@log = File.open("#{logdir}/ppool.log", 'w')
|
33
|
+
@stdout_log = {}
|
34
|
+
@stderr_log = {}
|
8
35
|
|
9
36
|
end
|
10
37
|
|
@@ -22,9 +49,31 @@ class ShellProcessController < BasicProcessController
|
|
22
49
|
|
23
50
|
end
|
24
51
|
|
52
|
+
def process_ended(pid, status)
|
53
|
+
|
54
|
+
if @rmlogs && status == 0
|
55
|
+
delete_log_file(pid, 'stderr')
|
56
|
+
delete_log_file(pid, 'stdout')
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
25
61
|
def info(m)
|
26
62
|
@log.write("#{m}\n")
|
27
63
|
@log.flush
|
28
64
|
end
|
29
65
|
|
66
|
+
|
67
|
+
def delete_log_file(pid, suffix)
|
68
|
+
begin
|
69
|
+
Dir.glob("#{@logdir}/process_#{pid}_*.#{suffix}") { |file|
|
70
|
+
info "deleting log file #{file} for process #{pid}"
|
71
|
+
File.delete(file)
|
72
|
+
}
|
73
|
+
rescue => e
|
74
|
+
info "error deleting log file for process #{pid}: #{e}"
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
30
79
|
end
|
@@ -1,14 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# MIT License
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Paul Taylor
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#
|
1
24
|
|
2
25
|
require 'io/console'
|
3
26
|
require 'io/wait'
|
4
27
|
|
5
28
|
class TerminalProcessController < ShellProcessController
|
6
29
|
|
7
|
-
def initialize(size, script, logdir)
|
8
|
-
super(script, logdir)
|
30
|
+
def initialize(size, delay, script, logdir, rmlogs)
|
31
|
+
super(script, logdir, rmlogs)
|
9
32
|
@finishing = false
|
10
33
|
@finished = false
|
11
34
|
@size = size
|
35
|
+
@delay = delay
|
12
36
|
@msg = ""
|
13
37
|
@last_stats = {}
|
14
38
|
@count = 0
|
@@ -30,9 +54,6 @@ class TerminalProcessController < ShellProcessController
|
|
30
54
|
def process_started(pid, num_processes)
|
31
55
|
end
|
32
56
|
|
33
|
-
def process_ended(pid, status)
|
34
|
-
end
|
35
|
-
|
36
57
|
def progress(stats)
|
37
58
|
|
38
59
|
if stats != @last_stats
|
@@ -51,7 +72,6 @@ class TerminalProcessController < ShellProcessController
|
|
51
72
|
process_keys
|
52
73
|
|
53
74
|
if @finishing
|
54
|
-
info "finishing #{stats[:active_processes]}"
|
55
75
|
if stats[:active_processes] == 0
|
56
76
|
@finished = true
|
57
77
|
end
|
@@ -61,7 +81,7 @@ class TerminalProcessController < ShellProcessController
|
|
61
81
|
end
|
62
82
|
|
63
83
|
def delay
|
64
|
-
return
|
84
|
+
return @delay / 1000
|
65
85
|
end
|
66
86
|
|
67
87
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -24,7 +24,8 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
-
description:
|
27
|
+
description: Start of pool of processes running a single command and control the pool
|
28
|
+
size via the keyboard.
|
28
29
|
email: pftylr@gmail.com
|
29
30
|
executables:
|
30
31
|
- ppool
|
@@ -48,9 +49,9 @@ require_paths:
|
|
48
49
|
- lib
|
49
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
|
-
- - "
|
52
|
+
- - "~>"
|
52
53
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
+
version: '2.0'
|
54
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
56
|
requirements:
|
56
57
|
- - ">="
|
@@ -58,8 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
59
|
version: '0'
|
59
60
|
requirements: []
|
60
61
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.
|
62
|
+
rubygems_version: 2.6.8
|
62
63
|
signing_key:
|
63
64
|
specification_version: 4
|
64
|
-
summary:
|
65
|
+
summary: Pool of processes running a single command
|
65
66
|
test_files: []
|