wolfpack 0.0.3 → 1.0.1
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/README.md +3 -1
- data/lib/wolfpack/version.rb +1 -1
- data/lib/wolfpack.rb +8 -31
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3b94a6f6dd6d481d9d187ab548bd5759b8b78f6
|
4
|
+
data.tar.gz: 551b2ca1dd025466d1540033a38c8d1bf8726815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 305c3f077623ae5874c1f59144ecfb72207fc827d63cf130330a256f0a0a7cb9b33216f0907c924a14161d17ad6b35b73359b0b1057366bfb0afe5f1c69115f9
|
7
|
+
data.tar.gz: b2f64f10ed193a827d23d59d78841f4ced2963621ad97cc6633e8090621a7c03f8f8301ffba6390cd00a87f1438cd28561f61a079d9d64529f6f45b5c5c23a61
|
data/README.md
CHANGED
@@ -58,7 +58,9 @@ Then run wolfpack with the config file.
|
|
58
58
|
```sh
|
59
59
|
# Running the wolfpack command on a 4 processor machine. Your machine might
|
60
60
|
# run with a different number of workers depending on processors.
|
61
|
-
$
|
61
|
+
$ wolfpack run 'echo "Using $DATABASE_URL"; rake db:create db:schema:load; rspec $SPEC_FILES;' \
|
62
|
+
-c config/wolfpack.rb
|
63
|
+
--args `find spec/**/**_spec.rb`
|
62
64
|
Using mysql2://localhost/app_test_0
|
63
65
|
Using mysql2://localhost/app_test_1
|
64
66
|
Using mysql2://localhost/app_test_2
|
data/lib/wolfpack/version.rb
CHANGED
data/lib/wolfpack.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "wolfpack/version"
|
2
2
|
require "thor"
|
3
3
|
require "parallel"
|
4
|
-
require "timeout"
|
5
4
|
|
6
5
|
module Wolfpack
|
7
6
|
# Gets the number of "processors" on the current machine. This does not map
|
@@ -11,9 +10,6 @@ module Wolfpack
|
|
11
10
|
@processor_count ||= Parallel.processor_count
|
12
11
|
end
|
13
12
|
|
14
|
-
# Wait 10 seconds before blowing up if stdio isn't reading any data.
|
15
|
-
STDIN_READ_TIMEOUT = 10
|
16
|
-
|
17
13
|
# Configure a runner instance
|
18
14
|
class Configurator
|
19
15
|
attr_reader :runner
|
@@ -42,7 +38,7 @@ module Wolfpack
|
|
42
38
|
|
43
39
|
# Create a command that will run with the give arguments. Optionally
|
44
40
|
# a path may be given to a configuration file that sets up a runner.
|
45
|
-
def initialize(command, args
|
41
|
+
def initialize(command, args, config_path = nil)
|
46
42
|
@command, @args = command, args
|
47
43
|
configure(config_path) if config_path
|
48
44
|
end
|
@@ -54,8 +50,9 @@ module Wolfpack
|
|
54
50
|
# make sure we have a number to work with.
|
55
51
|
processes ||= Wolfpack.processor_count
|
56
52
|
|
57
|
-
#
|
58
|
-
|
53
|
+
# If arguments exist then split args into groups of n processes.
|
54
|
+
# Otherwise run commands on every runner
|
55
|
+
partions = args ? partition(args, processes) : Array.new(processes){[]}
|
59
56
|
|
60
57
|
# Now run the command with the processes.
|
61
58
|
Parallel.each_with_index(partions, :in_processes => processes) do |args, n|
|
@@ -77,7 +74,9 @@ module Wolfpack
|
|
77
74
|
arr.each_with_index do |el, idx|
|
78
75
|
result[idx % n].push el
|
79
76
|
end
|
80
|
-
|
77
|
+
|
78
|
+
# Return only partitions with data in them
|
79
|
+
result.reject{|a| a.empty?}
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
@@ -91,29 +90,7 @@ module Wolfpack
|
|
91
90
|
# thor doesn't return an integer for its params.
|
92
91
|
processes = options[:processes].to_i if options[:processes]
|
93
92
|
|
94
|
-
|
95
|
-
args = options[:args]
|
96
|
-
|
97
|
-
# Otherwise read stdin from a pipe and split by lines.
|
98
|
-
if args.nil?
|
99
|
-
# Process stdin that's piped in.
|
100
|
-
if $stdin.tty?
|
101
|
-
args = [] # Screw it, lets return an empty array of args.
|
102
|
-
else
|
103
|
-
# Read from the pipe
|
104
|
-
buffer = ""
|
105
|
-
|
106
|
-
Timeout::timeout STDIN_READ_TIMEOUT do
|
107
|
-
until $stdin.eof? do
|
108
|
-
buffer << $stdin.read
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
args = buffer.lines
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
Wolfpack::Runner.new(command, args, options[:config]).run(processes)
|
93
|
+
Wolfpack::Runner.new(command, options[:args], options[:config]).run(processes)
|
117
94
|
end
|
118
95
|
|
119
96
|
desc "version", "Wolfpack version"
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wolfpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: thor
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: parallel
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Run stuff in parallel
|
@@ -88,8 +88,8 @@ executables:
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
-
|
92
|
-
-
|
91
|
+
- .gitignore
|
92
|
+
- .rspec
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
@@ -112,20 +112,21 @@ require_paths:
|
|
112
112
|
- lib
|
113
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - '>='
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.3.0
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Run ruby tasks in parallel
|
129
129
|
test_files:
|
130
130
|
- spec/lib/wolfpack.rb
|
131
131
|
- spec/spec_helper.rb
|
132
|
+
has_rdoc:
|