robot-controller 2.1.1 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -6
- data/.rubocop.yml +65 -0
- data/.rubocop_todo.yml +125 -50
- data/.travis.yml +1 -3
- data/README.md +7 -7
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/bin/controller +16 -16
- data/lib/robot-controller.rb +3 -3
- data/lib/robot-controller/eye.rb +63 -0
- data/lib/robot-controller/{robots.rb → parser.rb} +2 -2
- data/lib/robot-controller/verify.rb +1 -1
- data/robot-controller.gemspec +7 -8
- data/spec/spec_helper.rb +6 -3
- data/spec/unit/robots_spec.rb +1 -1
- metadata +21 -36
- data/lib/robot-controller/bluepill.rb +0 -91
- data/lib/tasks/yard.rake +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d10cfdbeb6647684ddf8c0e585d51861868c891891be6943b413c7dae7a3b46c
|
4
|
+
data.tar.gz: 5968e0e0cad1d8c1d1418f2e5dbe3174d8b80f505efea4f23d413635d87b9639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6773382a73c343037241646665d51f929f13d013e36f9f05d01a7e7cf8a906b641c6265c0461a477592050d41f3b7e71a8ebafdc081da2a40b88c4a6b45bb4b
|
7
|
+
data.tar.gz: 2d06490374d1309f9be8507c7cded879b115ab422f5776cfadfdc70ef53f8882274a88974bfab608abf29a16894a3bb8554dba8353f2b79a71486673c99286cb
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1 +1,66 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
# Turn on RSpec cops
|
4
|
+
require: rubocop-rspec
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
DisplayCopNames: true
|
8
|
+
Include:
|
9
|
+
- Rakefile
|
10
|
+
- 'lib/**/*.rake'
|
11
|
+
Exclude:
|
12
|
+
- '**/*.md'
|
13
|
+
- 'vendor/**/*' # avoid running rubocop on travis cached bundler
|
14
|
+
|
15
|
+
# --- Layout ---
|
16
|
+
|
17
|
+
Layout/EmptyLinesAroundBlockBody:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Layout/EmptyLinesAroundClassBody:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Layout/EmptyLinesAroundModuleBody:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# --- Lint ---
|
30
|
+
|
31
|
+
# --- Metrics ---
|
32
|
+
|
33
|
+
Metrics/BlockLength:
|
34
|
+
Exclude:
|
35
|
+
- spec/**/*
|
36
|
+
|
37
|
+
Metrics/LineLength:
|
38
|
+
Max: 123 # this isn't 1994
|
39
|
+
# spec/unit/verify_spec.rb line 35 is 123 chars; would like to get it down to 120
|
40
|
+
|
41
|
+
# --- Naming ---
|
42
|
+
|
43
|
+
Naming/FileName:
|
44
|
+
Exclude:
|
45
|
+
- Gemfile
|
46
|
+
- robot-controller.gemspec
|
47
|
+
- lib/robot-controller.rb
|
48
|
+
|
49
|
+
# --- Performance ---
|
50
|
+
|
51
|
+
# --- RSpec ---
|
52
|
+
|
53
|
+
RSpec/MessageSpies:
|
54
|
+
Enabled: false # receive is fine; have_received is fine
|
55
|
+
|
56
|
+
# --- Style ---
|
57
|
+
|
58
|
+
Style/FrozenStringLiteralComment:
|
59
|
+
Enabled: false # avoid cruft in our files for something that MAY be default in Ruby 3.0
|
60
|
+
|
61
|
+
Style/StringLiterals:
|
62
|
+
Enabled: false # ' vs " isn't a big deal for readability or maintainability or execution time
|
63
|
+
|
64
|
+
Style/SymbolArray:
|
65
|
+
Exclude:
|
66
|
+
- Rakefile # because [:spec, :rubocop] isn't a big deal
|
data/.rubocop_todo.yml
CHANGED
@@ -1,86 +1,152 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-12-10 08:36:11 -0600 using RuboCop version 0.52.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/OrderedDependencies:
|
14
|
+
Exclude:
|
15
|
+
- 'robot-controller.gemspec'
|
16
|
+
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
# Cop supports --auto-correct.
|
20
|
+
Layout/EmptyLineAfterMagicComment:
|
21
|
+
Exclude:
|
22
|
+
- 'robot-controller.gemspec'
|
23
|
+
|
24
|
+
# Offense count: 2
|
25
|
+
# Cop supports --auto-correct.
|
26
|
+
Layout/EmptyLinesAroundArguments:
|
27
|
+
Exclude:
|
28
|
+
- 'bin/controller'
|
29
|
+
|
30
|
+
# Offense count: 15
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
# Configuration parameters: IndentationWidth.
|
33
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
|
34
|
+
Layout/IndentArray:
|
35
|
+
EnforcedStyle: consistent
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Cop supports --auto-correct.
|
39
|
+
# Configuration parameters: EnforcedStyle.
|
40
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
41
|
+
Layout/MultilineArrayBraceLayout:
|
42
|
+
Exclude:
|
43
|
+
- 'spec/unit/verify_spec.rb'
|
44
|
+
|
45
|
+
# Offense count: 1
|
46
|
+
Lint/AmbiguousBlockAssociation:
|
47
|
+
Exclude:
|
48
|
+
- 'config/schedule_example.rb'
|
49
|
+
|
9
50
|
# Offense count: 3
|
10
51
|
Metrics/AbcSize:
|
11
|
-
Max:
|
52
|
+
Max: 80
|
12
53
|
|
13
|
-
# Offense count:
|
14
|
-
# Configuration parameters: CountComments.
|
54
|
+
# Offense count: 1
|
55
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
56
|
Metrics/BlockLength:
|
16
|
-
Max:
|
57
|
+
Max: 26
|
17
58
|
|
18
59
|
# Offense count: 1
|
60
|
+
# Configuration parameters: CountBlocks.
|
19
61
|
Metrics/BlockNesting:
|
20
62
|
Max: 4
|
21
63
|
|
22
64
|
# Offense count: 2
|
23
65
|
Metrics/CyclomaticComplexity:
|
24
|
-
Max:
|
25
|
-
|
26
|
-
# Offense count: 33
|
27
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
28
|
-
# URISchemes: http, https
|
29
|
-
Metrics/LineLength:
|
30
|
-
Max: 123
|
66
|
+
Max: 23
|
31
67
|
|
32
68
|
# Offense count: 5
|
33
69
|
# Configuration parameters: CountComments.
|
34
70
|
Metrics/MethodLength:
|
35
|
-
Max:
|
71
|
+
Max: 87
|
36
72
|
|
37
73
|
# Offense count: 2
|
38
74
|
Metrics/PerceivedComplexity:
|
39
|
-
Max:
|
75
|
+
Max: 20
|
40
76
|
|
41
|
-
# Offense count:
|
42
|
-
# Configuration parameters:
|
43
|
-
|
77
|
+
# Offense count: 14
|
78
|
+
# Configuration parameters: Prefixes.
|
79
|
+
# Prefixes: when, with, without
|
80
|
+
RSpec/ContextWording:
|
81
|
+
Exclude:
|
82
|
+
- 'spec/unit/robots_spec.rb'
|
83
|
+
- 'spec/unit/verify_spec.rb'
|
84
|
+
|
85
|
+
# Offense count: 12
|
86
|
+
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
87
|
+
# SupportedStyles: described_class, explicit
|
88
|
+
RSpec/DescribedClass:
|
44
89
|
Exclude:
|
45
|
-
- '
|
90
|
+
- 'spec/unit/robots_spec.rb'
|
91
|
+
- 'spec/unit/verify_spec.rb'
|
46
92
|
|
47
93
|
# Offense count: 1
|
48
|
-
|
49
|
-
# SupportedStyles: format, sprintf, percent
|
50
|
-
Style/FormatString:
|
94
|
+
RSpec/EmptyLineAfterSubject:
|
51
95
|
Exclude:
|
52
|
-
- '
|
96
|
+
- 'spec/unit/verify_spec.rb'
|
53
97
|
|
54
|
-
# Offense count:
|
55
|
-
# Configuration parameters:
|
56
|
-
|
98
|
+
# Offense count: 11
|
99
|
+
# Configuration parameters: Max.
|
100
|
+
RSpec/ExampleLength:
|
57
101
|
Exclude:
|
58
|
-
- '
|
59
|
-
- '
|
102
|
+
- 'spec/unit/robots_spec.rb'
|
103
|
+
- 'spec/unit/verify_spec.rb'
|
60
104
|
|
61
|
-
# Offense count:
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
105
|
+
# Offense count: 2
|
106
|
+
# Configuration parameters: CustomTransform, IgnoreMethods.
|
107
|
+
RSpec/FilePath:
|
108
|
+
Exclude:
|
109
|
+
- 'spec/unit/robots_spec.rb'
|
110
|
+
- 'spec/unit/verify_spec.rb'
|
111
|
+
|
112
|
+
# Offense count: 7
|
113
|
+
# Configuration parameters: AggregateFailuresByDefault.
|
114
|
+
RSpec/MultipleExpectations:
|
115
|
+
Max: 6
|
116
|
+
|
117
|
+
# Offense count: 30
|
118
|
+
RSpec/NamedSubject:
|
119
|
+
Exclude:
|
120
|
+
- 'spec/unit/robots_spec.rb'
|
121
|
+
- 'spec/unit/verify_spec.rb'
|
122
|
+
|
123
|
+
# Offense count: 8
|
124
|
+
RSpec/SubjectStub:
|
125
|
+
Exclude:
|
126
|
+
- 'spec/unit/verify_spec.rb'
|
67
127
|
|
68
128
|
# Offense count: 1
|
69
129
|
# Cop supports --auto-correct.
|
70
|
-
|
71
|
-
# SupportedStyles: symmetrical, new_line, same_line
|
72
|
-
Style/MultilineArrayBraceLayout:
|
130
|
+
Style/Encoding:
|
73
131
|
Exclude:
|
74
|
-
- '
|
132
|
+
- 'robot-controller.gemspec'
|
133
|
+
|
134
|
+
# Offense count: 3
|
135
|
+
# Configuration parameters: MinBodyLength.
|
136
|
+
Style/GuardClause:
|
137
|
+
Exclude:
|
138
|
+
- 'lib/robot-controller/parser.rb'
|
139
|
+
- 'lib/robot-controller/verify.rb'
|
75
140
|
|
76
141
|
# Offense count: 5
|
77
142
|
# Cop supports --auto-correct.
|
143
|
+
# Configuration parameters: Strict.
|
78
144
|
Style/NumericLiterals:
|
79
145
|
MinDigits: 6
|
80
146
|
|
81
147
|
# Offense count: 5
|
82
148
|
# Cop supports --auto-correct.
|
83
|
-
# Configuration parameters: AutoCorrect, EnforcedStyle
|
149
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
84
150
|
# SupportedStyles: predicate, comparison
|
85
151
|
Style/NumericPredicate:
|
86
152
|
Exclude:
|
@@ -88,30 +154,39 @@ Style/NumericPredicate:
|
|
88
154
|
- 'bin/controller'
|
89
155
|
- 'lib/robot-controller/verify.rb'
|
90
156
|
|
91
|
-
# Offense count:
|
157
|
+
# Offense count: 10
|
92
158
|
# Cop supports --auto-correct.
|
93
|
-
# Configuration parameters:
|
94
|
-
|
95
|
-
Style/SignalException:
|
159
|
+
# Configuration parameters: PreferredDelimiters.
|
160
|
+
Style/PercentLiteralDelimiters:
|
96
161
|
Exclude:
|
97
|
-
- '
|
98
|
-
- '
|
99
|
-
- 'lib/robot-controller/verify.rb'
|
162
|
+
- 'spec/unit/robots_spec.rb'
|
163
|
+
- 'spec/unit/verify_spec.rb'
|
100
164
|
|
101
165
|
# Offense count: 1
|
102
|
-
#
|
103
|
-
#
|
104
|
-
|
166
|
+
# Cop supports --auto-correct.
|
167
|
+
# Configuration parameters: EnforcedStyle.
|
168
|
+
# SupportedStyles: implicit, explicit
|
169
|
+
Style/RescueStandardError:
|
170
|
+
Exclude:
|
171
|
+
- 'bin/controller'
|
172
|
+
|
173
|
+
# Offense count: 12
|
174
|
+
# Cop supports --auto-correct.
|
175
|
+
# Configuration parameters: EnforcedStyle.
|
176
|
+
# SupportedStyles: only_raise, only_fail, semantic
|
177
|
+
Style/SignalException:
|
105
178
|
Exclude:
|
179
|
+
- 'bin/controller'
|
180
|
+
- 'lib/robot-controller/parser.rb'
|
106
181
|
- 'lib/robot-controller/verify.rb'
|
107
182
|
|
108
183
|
# Offense count: 2
|
109
184
|
# Cop supports --auto-correct.
|
110
|
-
# Configuration parameters: EnforcedStyle,
|
185
|
+
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
|
111
186
|
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
112
187
|
Style/TernaryParentheses:
|
113
188
|
Exclude:
|
114
|
-
- 'lib/robot-controller/
|
189
|
+
- 'lib/robot-controller/parser.rb'
|
115
190
|
- 'lib/robot-controller/verify.rb'
|
116
191
|
|
117
192
|
# Offense count: 7
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/sul-dlss/robot-controller.svg?branch=master)](https://travis-ci.org/sul-dlss/robot-controller)
|
2
|
-
[![
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/github/sul-dlss/robot-controller/badge.svg)](https://coveralls.io/github/sul-dlss/robot-controller)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/robot-controller.svg)](https://badge.fury.io/rb/robot-controller)
|
4
4
|
|
5
5
|
robot-controller
|
@@ -25,10 +25,10 @@ Then to use the controller to boot the robots:
|
|
25
25
|
|
26
26
|
bundle exec controller boot
|
27
27
|
|
28
|
-
If you want to *override* the
|
28
|
+
If you want to *override* the eye configuration but still use the
|
29
29
|
controller (though NOT recommended), then add:
|
30
30
|
|
31
|
-
config/
|
31
|
+
config/eye.rb
|
32
32
|
|
33
33
|
### Usage
|
34
34
|
|
@@ -38,16 +38,16 @@ controller (though NOT recommended), then add:
|
|
38
38
|
controller [--help]
|
39
39
|
|
40
40
|
Example:
|
41
|
-
controller boot # start
|
41
|
+
controller boot # start eyed and jobs
|
42
42
|
controller status # check on status of jobs
|
43
43
|
controller verify # verify robots are running as configured
|
44
44
|
controller log robot01_01_dor_accessionWF_descriptive-metadata # view log for worker
|
45
45
|
controller stop # stop jobs
|
46
|
-
controller quit # stop
|
46
|
+
controller quit # stop eyed
|
47
47
|
|
48
48
|
Environment:
|
49
|
-
|
50
|
-
|
49
|
+
EYE_BASEDIR - where eye stores its state (default: run/eye)
|
50
|
+
EYE_LOGFILE - output log (default: log/eye.log)
|
51
51
|
ROBOT_ENVIRONMENT - (default: development)
|
52
52
|
|
53
53
|
### Changes
|
data/Rakefile
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'rake'
|
3
|
-
require 'bundler'
|
4
2
|
require 'bundler/gem_tasks'
|
5
|
-
require 'rspec/core/rake_task'
|
6
3
|
require 'version_bumper'
|
7
4
|
require 'robot-controller/tasks'
|
8
5
|
|
9
6
|
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
10
7
|
|
11
|
-
task default: [:spec, :rubocop
|
8
|
+
task default: [:spec, :rubocop]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0.beta1
|
data/bin/controller
CHANGED
@@ -16,44 +16,44 @@ module RobotController
|
|
16
16
|
controller [--help]
|
17
17
|
|
18
18
|
Example:
|
19
|
-
% controller boot # start
|
19
|
+
% controller boot # start eyed and jobs
|
20
20
|
% controller status # check on status of jobs
|
21
21
|
% controller log dor_accessionWF_descriptive-metadata # view log for worker
|
22
22
|
% controller verify # verify robots are running as configured
|
23
23
|
% controller stop # stop jobs
|
24
|
-
% controller quit # stop
|
24
|
+
% controller quit # stop eyed
|
25
25
|
|
26
26
|
Environment:
|
27
|
-
|
28
|
-
|
27
|
+
EYE_BASEDIR - where bluepill stores its state (default: run/eye)
|
28
|
+
EYE_LOGFILE - output log (default: log/eye.log)
|
29
29
|
ROBOT_ENVIRONMENT - (default: development)
|
30
30
|
'
|
31
31
|
exit(-1)
|
32
32
|
end
|
33
33
|
|
34
34
|
ENV['ROBOT_ENVIRONMENT'] ||= 'development'
|
35
|
-
ENV['
|
36
|
-
ENV['
|
35
|
+
ENV['EYE_BASE_DIR'] ||= File.expand_path('run/eye')
|
36
|
+
ENV['EYE_LOGFILE'] ||= File.expand_path('log/eye.log')
|
37
37
|
|
38
|
-
fail '
|
39
|
-
fail 'bluepill requires run directory' unless File.directory?(File.dirname(ENV['BLUEPILL_BASE_DIR']))
|
40
|
-
fail 'bluepill requires log directory' unless File.directory?(File.dirname(ENV['BLUEPILL_LOGFILE']))
|
38
|
+
fail 'eye requires config directory' unless File.directory?('config')
|
41
39
|
|
42
|
-
cmd = '
|
43
|
-
cmd <<
|
44
|
-
cmd << " --
|
45
|
-
cmd << " --logfile #{ENV['BLUEPILL_LOGFILE']}"
|
40
|
+
cmd = 'eye'
|
41
|
+
# cmd << " --dir #{ENV['EYE_BASE_DIR']}"
|
42
|
+
# cmd << " --logger #{ENV['EYE_LOGFILE']}"
|
46
43
|
|
47
44
|
case args.first.downcase
|
45
|
+
when 'status'
|
46
|
+
exec "#{cmd} info -j"
|
47
|
+
exit(0)
|
48
48
|
when 'boot'
|
49
|
-
fn = 'config/
|
50
|
-
fn = RobotController.
|
49
|
+
fn = 'config/eye.rb' # allow override
|
50
|
+
fn = RobotController.eye_config unless File.file?(fn)
|
51
51
|
if File.file?(fn)
|
52
52
|
# puts "Loading #{fn}"
|
53
53
|
exec "#{cmd} load #{fn}"
|
54
54
|
# NOTREACHED
|
55
55
|
end
|
56
|
-
puts "ERROR: Cannot find
|
56
|
+
puts "ERROR: Cannot find eye configuration file for #{ENV['ROBOT_ENVIRONMENT']}"
|
57
57
|
exit(-1)
|
58
58
|
when 'verify'
|
59
59
|
verbose = (args[1] == '--verbose')
|
data/lib/robot-controller.rb
CHANGED
@@ -3,10 +3,10 @@ module RobotController
|
|
3
3
|
# e.g., `1.2.3`
|
4
4
|
VERSION = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION')).strip
|
5
5
|
|
6
|
-
def self.
|
7
|
-
File.join(File.dirname(__FILE__), 'robot-controller', '
|
6
|
+
def self.eye_config
|
7
|
+
File.join(File.dirname(__FILE__), 'robot-controller', 'eye.rb')
|
8
8
|
end
|
9
9
|
|
10
10
|
autoload :Verify, 'robot-controller/verify'
|
11
|
-
autoload :Parser, 'robot-controller/
|
11
|
+
autoload :Parser, 'robot-controller/parser'
|
12
12
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'robot-controller'
|
2
|
+
|
3
|
+
# current directory
|
4
|
+
WORKDIR = Dir.pwd
|
5
|
+
|
6
|
+
# setup robots configuration
|
7
|
+
robot_environment = ENV['ROBOT_ENVIRONMENT'] || 'development'
|
8
|
+
ROBOTS = RobotController::Parser.load("robots_#{robot_environment}.yml")
|
9
|
+
#
|
10
|
+
# Expect ROBOTS = [
|
11
|
+
# {:robot => 'x', :queues => ['a', 'b'], :n => 1}
|
12
|
+
# {:robot => 'z', :queues => ['b'], :n => 3}
|
13
|
+
# ]
|
14
|
+
#
|
15
|
+
|
16
|
+
# set application name to parent directory name
|
17
|
+
Eye.application File.basename(File.dirname(File.dirname(WORKDIR))),
|
18
|
+
log_file: "#{WORKDIR}/log/eye.log" do
|
19
|
+
app.working_dir = WORKDIR
|
20
|
+
|
21
|
+
env 'TERM_CHILD' => '1', # TERM, KILL, USR1 sent to worker process if running
|
22
|
+
'RESQUE_TERM_TIMEOUT' => '10.0', # seconds to wait before sending KILL after TERM
|
23
|
+
'INTERVAL' => '5',
|
24
|
+
'ROBOT_ENVIRONMENT' => robot_environment
|
25
|
+
|
26
|
+
env 'VERBOSE' => 'yes' if ENV['ROBOT_VERBOSE'] == 'yes'
|
27
|
+
env 'VVERBOSE' => 'yes' if ENV['ROBOT_VVERBOSE'] == 'yes'
|
28
|
+
|
29
|
+
group robot_environment do
|
30
|
+
ROBOTS.each_index do |i|
|
31
|
+
group ROBOTS[i][:robot] do
|
32
|
+
ROBOTS[i][:n].to_i.times do |j|
|
33
|
+
# prefix process name with index number to prevent duplicate process names
|
34
|
+
prefix = format('robot%02d_%02d', i + 1, j + 1)
|
35
|
+
|
36
|
+
process("#{prefix}_#{ROBOTS[i][:robot]}") do
|
37
|
+
puts "Creating robot #{process.name}"
|
38
|
+
|
39
|
+
# queue order is *VERY* important
|
40
|
+
queues = ROBOTS[i][:queues].join(',')
|
41
|
+
|
42
|
+
# use environment for these resque variables
|
43
|
+
env 'QUEUES' => queues
|
44
|
+
|
45
|
+
# process configuration
|
46
|
+
stdall "#{WORKDIR}/log/#{ROBOTS[i][:robot]}.log"
|
47
|
+
|
48
|
+
# spawn worker processes using robot-controller
|
49
|
+
start_command 'rake environment resque:work'
|
50
|
+
|
51
|
+
# we use eye to daemonize the resque workers rather than using
|
52
|
+
# resque's BACKGROUND flag
|
53
|
+
daemonize true
|
54
|
+
|
55
|
+
# graceful stops
|
56
|
+
stop_grace 360.seconds
|
57
|
+
stop_signals [:QUIT, 300.seconds, :TERM, 10.seconds, :KILL]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -9,9 +9,9 @@ module RobotController
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
# main entry point
|
12
|
-
def load(robots_fn, dir = 'config/environments', host = nil)
|
12
|
+
def load(robots_fn, dir = './config/environments', host = nil)
|
13
13
|
# Validate parameters
|
14
|
-
robots_fn = File.
|
14
|
+
robots_fn = File.expand_path(robots_fn, File.expand_path(dir))
|
15
15
|
fail "FileNotFound: #{robots_fn}" unless File.file?(robots_fn)
|
16
16
|
|
17
17
|
# read the YAML file with the configuration of all the robots to run
|
@@ -159,7 +159,7 @@ module RobotController
|
|
159
159
|
end
|
160
160
|
|
161
161
|
#
|
162
|
-
# @param [String] line as
|
162
|
+
# @param [String] line as eye outputs them...
|
163
163
|
# robot01_01_dor_gisAssemblyWF_assign-placenames(pid:29481): up
|
164
164
|
# robot02_01_dor_gisAssemblyWF_author-data(pid:29697): down
|
165
165
|
# robot03_01_dor_gisAssemblyWF_author-metadata(pid:29512): unmonitored
|
data/robot-controller.gemspec
CHANGED
@@ -22,16 +22,15 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.required_rubygems_version = '>= 1.3.6'
|
24
24
|
|
25
|
-
s.add_dependency '
|
26
|
-
s.add_dependency 'resque', '~>
|
27
|
-
s.add_dependency 'rake'
|
28
|
-
s.add_dependency 'whenever'
|
25
|
+
s.add_dependency 'eye'
|
26
|
+
s.add_dependency 'resque', '~> 2.0'
|
27
|
+
s.add_dependency 'rake'
|
28
|
+
s.add_dependency 'whenever'
|
29
29
|
|
30
|
+
s.add_development_dependency 'coveralls'
|
30
31
|
s.add_development_dependency 'pry'
|
31
32
|
s.add_development_dependency 'rspec'
|
32
|
-
s.add_development_dependency '
|
33
|
-
s.add_development_dependency 'rubocop'
|
34
|
-
s.add_development_dependency 'simplecov'
|
33
|
+
s.add_development_dependency 'rubocop', '~> 0.52.1' # avoid code churn due to rubocop changes
|
34
|
+
s.add_development_dependency 'rubocop-rspec'
|
35
35
|
s.add_development_dependency 'version_bumper'
|
36
|
-
s.add_development_dependency 'yard'
|
37
36
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,13 +4,16 @@ ENV['ROBOT_ENVIRONMENT'] ||= 'development'
|
|
4
4
|
ENV['ROBOT_LOG'] ||= '/dev/null'
|
5
5
|
ENV['ROBOT_LOG_LEVEL'] ||= 'debug'
|
6
6
|
|
7
|
+
require 'coveralls'
|
8
|
+
Coveralls.wear!
|
7
9
|
require 'simplecov'
|
8
|
-
SimpleCov.
|
10
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter 'spec'
|
13
|
+
end
|
9
14
|
|
10
15
|
require 'bundler/setup'
|
11
16
|
Bundler.require(:default, :development)
|
12
17
|
|
13
18
|
RSpec.configure do |_config|
|
14
19
|
end
|
15
|
-
|
16
|
-
Rails = Object.new unless defined? Rails
|
data/spec/unit/robots_spec.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robot-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Hardy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: eye
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -30,50 +30,36 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: whenever
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.9.2
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.9.2
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: '0'
|
76
|
-
type: :
|
62
|
+
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: coveralls
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
@@ -95,7 +81,7 @@ dependencies:
|
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: pry
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ">="
|
@@ -109,7 +95,7 @@ dependencies:
|
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: rspec
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
@@ -123,21 +109,21 @@ dependencies:
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: rubocop
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
|
-
- - "
|
115
|
+
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
117
|
+
version: 0.52.1
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
|
-
- - "
|
122
|
+
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: 0.52.1
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: rubocop-rspec
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - ">="
|
@@ -151,7 +137,7 @@ dependencies:
|
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
140
|
+
name: version_bumper
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - ">="
|
@@ -189,13 +175,12 @@ files:
|
|
189
175
|
- example/config/environments/robots_development.yml
|
190
176
|
- example/lib/tasks/environment.rake
|
191
177
|
- lib/robot-controller.rb
|
192
|
-
- lib/robot-controller/
|
193
|
-
- lib/robot-controller/
|
178
|
+
- lib/robot-controller/eye.rb
|
179
|
+
- lib/robot-controller/parser.rb
|
194
180
|
- lib/robot-controller/tasks.rb
|
195
181
|
- lib/robot-controller/verify.rb
|
196
182
|
- lib/tasks/rspec.rake
|
197
183
|
- lib/tasks/rubocop.rake
|
198
|
-
- lib/tasks/yard.rake
|
199
184
|
- robot-controller.gemspec
|
200
185
|
- spec/fixtures/matcher.yml
|
201
186
|
- spec/fixtures/multi.yml
|
@@ -224,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
209
|
version: 1.3.6
|
225
210
|
requirements: []
|
226
211
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.
|
212
|
+
rubygems_version: 2.7.6
|
228
213
|
signing_key:
|
229
214
|
specification_version: 4
|
230
215
|
summary: Monitors and controls running workflow robots off of priority queues and
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'robot-controller'
|
2
|
-
|
3
|
-
# current directory
|
4
|
-
WORKDIR = Dir.pwd
|
5
|
-
|
6
|
-
# setup robots configuration
|
7
|
-
robot_environment = ENV['ROBOT_ENVIRONMENT'] || 'development'
|
8
|
-
ROBOTS = RobotController::Parser.load("robots_#{robot_environment}.yml")
|
9
|
-
#
|
10
|
-
# Expect ROBOTS = [
|
11
|
-
# {:robot => 'x', :queues => ['a', 'b'], :n => 1}
|
12
|
-
# {:robot => 'z', :queues => ['b'], :n => 3}
|
13
|
-
# ]
|
14
|
-
#
|
15
|
-
|
16
|
-
# set application name to parent directory name
|
17
|
-
Bluepill.application File.basename(File.dirname(File.dirname(WORKDIR))),
|
18
|
-
log_file: "#{WORKDIR}/log/bluepill.log" do |app|
|
19
|
-
app.working_dir = WORKDIR
|
20
|
-
ROBOTS.each_index do |i|
|
21
|
-
ROBOTS[i][:n].to_i.times do |j|
|
22
|
-
# prefix process name with index number to prevent duplicate process names
|
23
|
-
prefix = sprintf('robot%02d_%02d', i + 1, j + 1)
|
24
|
-
app.process("#{prefix}_#{ROBOTS[i][:robot]}") do |process|
|
25
|
-
puts "Creating robot #{process.name}"
|
26
|
-
|
27
|
-
# queue order is *VERY* important
|
28
|
-
queues = ROBOTS[i][:queues].join(',')
|
29
|
-
|
30
|
-
# use environment for these resque variables
|
31
|
-
process.environment = {
|
32
|
-
'TERM_CHILD' => '1', # TERM, KILL, USR1 sent to worker process if running
|
33
|
-
'RESQUE_TERM_TIMEOUT' => '10.0', # seconds to wait before sending KILL after TERM
|
34
|
-
'QUEUES' => queues,
|
35
|
-
'ROBOT_ENVIRONMENT' => robot_environment,
|
36
|
-
'INTERVAL' => '5'
|
37
|
-
}
|
38
|
-
process.environment['VERBOSE'] = 'yes' if ENV['ROBOT_VERBOSE'] == 'yes'
|
39
|
-
process.environment['VVERBOSE'] = 'yes' if ENV['ROBOT_VVERBOSE'] == 'yes'
|
40
|
-
|
41
|
-
# process configuration
|
42
|
-
process.group = robot_environment
|
43
|
-
process.stdout = process.stderr = "#{WORKDIR}/log/#{ROBOTS[i][:robot]}.log"
|
44
|
-
|
45
|
-
# spawn worker processes using robot-controller
|
46
|
-
process.start_command = 'rake environment resque:work'
|
47
|
-
|
48
|
-
# we use bluepill to daemonize the resque workers rather than using
|
49
|
-
# resque's BACKGROUND flag
|
50
|
-
process.daemonize = true
|
51
|
-
|
52
|
-
# bluepill manages pid files
|
53
|
-
# process.pid_file = "#{WORKDIR}/run/#{process.name}.pid"
|
54
|
-
|
55
|
-
# graceful stops
|
56
|
-
process.stop_grace_time = 360.seconds # must be greater than stop_signals total
|
57
|
-
process.stop_signals = [
|
58
|
-
:quit, 300.seconds, # waits for jobs, then exits gracefully
|
59
|
-
:term, 10.seconds, # kills jobs and exits
|
60
|
-
:kill # no mercy
|
61
|
-
]
|
62
|
-
|
63
|
-
# process monitoring
|
64
|
-
|
65
|
-
# backoff if process is flapping between states
|
66
|
-
# process.checks :flapping,
|
67
|
-
# :times => 2, :within => 30.seconds,
|
68
|
-
# :retry_in => 7.seconds
|
69
|
-
|
70
|
-
# restart if process runs for longer than 15 mins of CPU time
|
71
|
-
# process.checks :running_time,
|
72
|
-
# :every => 5.minutes, :below => 15.minutes
|
73
|
-
|
74
|
-
# restart if CPU usage > 75% for 3 times, check every 10 seconds
|
75
|
-
# process.checks :cpu_usage,
|
76
|
-
# :every => 10.seconds,
|
77
|
-
# :below => 75, :times => 3,
|
78
|
-
# :include_children => true
|
79
|
-
#
|
80
|
-
# restart the process or any of its children
|
81
|
-
# if MEM usage > 100MB for 3 times, check every 10 seconds
|
82
|
-
# process.checks :mem_usage,
|
83
|
-
# :every => 10.seconds,
|
84
|
-
# :below => 100.megabytes, :times => 3,
|
85
|
-
# :include_children => true
|
86
|
-
|
87
|
-
# NOTE: there is an implicit process.keepalive
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
data/lib/tasks/yard.rake
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'yard'
|
3
|
-
YARD::Rake::YardocTask.new do |t|
|
4
|
-
t.files = ['lib/**/*.rb', 'bin/controller']
|
5
|
-
t.options = ['--readme', 'README.md', '-m', 'markdown']
|
6
|
-
end
|
7
|
-
|
8
|
-
namespace :yard do
|
9
|
-
desc 'Clean up documentation'
|
10
|
-
task :clean do
|
11
|
-
FileUtils.rm_rf('doc')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
rescue LoadError
|
15
|
-
abort 'Please install the YARD gem to generate doc.'
|
16
|
-
end
|