gina-conveyor 0.2.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +14 -9
- data/bin/conveyor +1 -0
- data/conveyor.gemspec +1 -0
- data/lib/conveyor.rb +1 -0
- data/lib/conveyor/foreman.rb +2 -1
- data/lib/conveyor/output/email.rb +7 -7
- data/lib/conveyor/version.rb +1 -1
- data/lib/conveyor/websocket.rb +3 -6
- data/lib/conveyor/worker.rb +13 -13
- data/lib/conveyor/workers/syntax.rb +39 -32
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08fc3174aa43d6d5eb64bfec83f61eadf806f0b3
|
4
|
+
data.tar.gz: fb2d81a0e75ffc1a620630831f9f8f1e9b5d37af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 589d9f31d1621aea95ac881210703e72a56165c8d53c7c59e472e2e4fb9c1677b3109d32fae779dfe7abf52ef21ab478b7fc81549b5a59bf6091352f96acb81d
|
7
|
+
data.tar.gz: 718daf0c2872ed754c6dfd24207dfac7ef6981678aa718c639c5a93e06be39916e38aa3a40107d5f82738047565964085fb3344c561831893e388df60b0b83da
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gina-conveyor (0.
|
4
|
+
gina-conveyor (1.0.0)
|
5
5
|
activemodel (~> 4.1.0)
|
6
6
|
activesupport (~> 4.1.0)
|
7
7
|
em-websocket (~> 0.5.1)
|
8
8
|
eventmachine (~> 1.0.0)
|
9
9
|
listen (~> 2.10)
|
10
|
+
mixlib-shellout (~> 2.2.1)
|
10
11
|
rainbow (~> 2.0.0)
|
11
12
|
rb-readline (~> 0.5.0)
|
12
13
|
|
13
14
|
GEM
|
14
15
|
remote: http://rubygems.org/
|
15
16
|
specs:
|
16
|
-
activemodel (4.1.
|
17
|
-
activesupport (= 4.1.
|
17
|
+
activemodel (4.1.13)
|
18
|
+
activesupport (= 4.1.13)
|
18
19
|
builder (~> 3.1)
|
19
|
-
activesupport (4.1.
|
20
|
+
activesupport (4.1.13)
|
20
21
|
i18n (~> 0.6, >= 0.6.9)
|
21
22
|
json (~> 1.7, >= 1.7.7)
|
22
23
|
minitest (~> 5.1)
|
@@ -28,9 +29,9 @@ GEM
|
|
28
29
|
em-websocket (0.5.1)
|
29
30
|
eventmachine (>= 0.12.9)
|
30
31
|
http_parser.rb (~> 0.6.0)
|
31
|
-
eventmachine (1.0.
|
32
|
+
eventmachine (1.0.8)
|
32
33
|
ffi (1.9.10)
|
33
|
-
hitimes (1.2.
|
34
|
+
hitimes (1.2.3)
|
34
35
|
http_parser.rb (0.6.0)
|
35
36
|
i18n (0.7.0)
|
36
37
|
json (1.8.3)
|
@@ -38,15 +39,16 @@ GEM
|
|
38
39
|
celluloid (~> 0.16.0)
|
39
40
|
rb-fsevent (>= 0.9.3)
|
40
41
|
rb-inotify (>= 0.9)
|
41
|
-
minitest (5.
|
42
|
+
minitest (5.8.1)
|
43
|
+
mixlib-shellout (2.2.1)
|
42
44
|
rainbow (2.0.0)
|
43
45
|
rake (10.3.2)
|
44
|
-
rb-fsevent (0.9.
|
46
|
+
rb-fsevent (0.9.6)
|
45
47
|
rb-inotify (0.9.5)
|
46
48
|
ffi (>= 0.5.0)
|
47
49
|
rb-readline (0.5.3)
|
48
50
|
thread_safe (0.3.5)
|
49
|
-
timers (4.0.
|
51
|
+
timers (4.0.4)
|
50
52
|
hitimes
|
51
53
|
tzinfo (1.2.2)
|
52
54
|
thread_safe (~> 0.1)
|
@@ -57,3 +59,6 @@ PLATFORMS
|
|
57
59
|
DEPENDENCIES
|
58
60
|
gina-conveyor!
|
59
61
|
rake
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.10.6
|
data/bin/conveyor
CHANGED
data/conveyor.gemspec
CHANGED
data/lib/conveyor.rb
CHANGED
data/lib/conveyor/foreman.rb
CHANGED
@@ -31,8 +31,9 @@ module Conveyor
|
|
31
31
|
"worker_defs" => File.expand_path('.workers', Dir.pwd),
|
32
32
|
"logfile" => File.expand_path('log/conveyor.log', Dir.pwd),
|
33
33
|
"threadpool" => 5,
|
34
|
+
"command_timeout" => 600,
|
34
35
|
"websocket" => {
|
35
|
-
"disabled" =>
|
36
|
+
"disabled" => true,
|
36
37
|
"host" => "0.0.0.0",
|
37
38
|
"port" => 9876
|
38
39
|
}
|
@@ -11,11 +11,11 @@ module Conveyor
|
|
11
11
|
def reset!
|
12
12
|
@msg_queue = []
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def warning(*msg)
|
16
16
|
# Do nothing
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def error(*msg)
|
20
20
|
@msg_queue ||= []
|
21
21
|
options = msg.extract_options!
|
@@ -23,20 +23,20 @@ module Conveyor
|
|
23
23
|
msg = msg.join("\n") if msg.class == Array
|
24
24
|
@msg_queue << msg
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def write(msgtype, *msg)
|
28
28
|
if respond_to?(msgtype)
|
29
29
|
self.send(msgtype, *msg)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def mail
|
34
34
|
return if @msg_queue.nil? || @msg_queue.empty?
|
35
|
-
puts "Sending email to #{Conveyor::Foreman.instance.notify_list}"
|
36
|
-
puts @msg_queue
|
35
|
+
# puts "Sending email to #{Conveyor::Foreman.instance.notify_list}"
|
36
|
+
# puts @msg_queue
|
37
37
|
reset!
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
data/lib/conveyor/version.rb
CHANGED
data/lib/conveyor/websocket.rb
CHANGED
@@ -2,13 +2,10 @@ module Conveyor
|
|
2
2
|
class Websocket
|
3
3
|
class << self
|
4
4
|
def start
|
5
|
-
if config[:
|
6
|
-
fm.info "Websocket disabled"
|
7
|
-
return
|
8
|
-
end
|
5
|
+
return if config[:disabled]
|
9
6
|
|
10
7
|
fm.info "Starting websocket on #{config[:host]}:#{config[:port]}", :color => :green
|
11
|
-
|
8
|
+
|
12
9
|
EventMachine::start_server(config[:host], config[:port],
|
13
10
|
EventMachine::WebSocket::Connection, config) do |ws|
|
14
11
|
ws.onopen {
|
@@ -34,4 +31,4 @@ module Conveyor
|
|
34
31
|
end
|
35
32
|
end
|
36
33
|
end
|
37
|
-
end
|
34
|
+
end
|
data/lib/conveyor/worker.rb
CHANGED
@@ -7,7 +7,7 @@ module Conveyor
|
|
7
7
|
class Worker
|
8
8
|
include Conveyor::Output
|
9
9
|
include Conveyor::Workers::Syntax
|
10
|
-
|
10
|
+
|
11
11
|
attr_accessor :filename
|
12
12
|
attr_reader :status
|
13
13
|
attr_reader :worker_def
|
@@ -32,13 +32,13 @@ module Conveyor
|
|
32
32
|
dir = File.dirname(worker_def)
|
33
33
|
File.expand_path(File.basename(worker_def, '.worker') + '.log', dir)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
# Catch any calls to error and set the status fail flags
|
37
37
|
def error(*msg)
|
38
38
|
opts = msg.extract_options!
|
39
39
|
unless msg.flatten.empty?
|
40
40
|
@status.fail!
|
41
|
-
msg.unshift("Error encountered in #{worker_def}")
|
41
|
+
# msg.unshift("Error encountered in #{worker_def}")
|
42
42
|
super(*msg, opts)
|
43
43
|
end
|
44
44
|
@status.success?
|
@@ -58,14 +58,14 @@ module Conveyor
|
|
58
58
|
if @status.success?
|
59
59
|
info "Completed #{@filename}, #{@elapsed}s elapsed", :color => :green
|
60
60
|
else
|
61
|
-
error "Error
|
61
|
+
error "Error encountered in #{@worker_def} -> #{@filename}", :color => :red
|
62
62
|
end
|
63
63
|
send_notifications
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
protected
|
68
|
-
|
68
|
+
|
69
69
|
def create_dirs_for_cmd(src, dest)
|
70
70
|
if src.is_a?(Array) || Array.wrap(src).count > 1 || dest.last == ?/
|
71
71
|
mkdir(dest)
|
@@ -73,34 +73,34 @@ module Conveyor
|
|
73
73
|
mkdir(File.dirname(dest))
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def verified_cmd(cmd, src, dest, &block)
|
78
78
|
create_dirs_for_cmd(src, dest)
|
79
79
|
dest = File.expand_path(dest)
|
80
|
-
|
80
|
+
|
81
81
|
Array.wrap(src).each do |s|
|
82
82
|
run "#{cmd} #{s} #{dest}"
|
83
83
|
sync
|
84
|
-
|
84
|
+
|
85
85
|
if block_given?
|
86
86
|
result = yield(s, dest)
|
87
87
|
@status.fail! unless result
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
def verified_move(src, dest)
|
93
93
|
verified_cmd(:mv, src, dest) do |src,dest|
|
94
94
|
verify_move(src,dest)
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
def verified_copy(src, dest)
|
99
99
|
verified_cmd(:cp, src, dest) do |src,dest|
|
100
100
|
verify_copy(src,dest)
|
101
101
|
end
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
def verify_copy(src, dest)
|
105
105
|
if File.directory? dest
|
106
106
|
File.exists?(File.join(dest, File.basename(src)))
|
@@ -108,7 +108,7 @@ module Conveyor
|
|
108
108
|
File.exists?(dest)
|
109
109
|
end
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def verify_move(src, dest)
|
113
113
|
if File.directory? dest
|
114
114
|
File.exists?(File.join(dest, File.basename(src))) && !File.exists?(src)
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Conveyor
|
2
2
|
module Workers
|
3
3
|
module Syntax
|
4
|
-
|
4
|
+
|
5
5
|
# Will return a string of any method returned that isn't handled
|
6
6
|
# ex: match extension txt => match(extension("foo"))
|
7
7
|
def method_missing(method, value = nil)
|
8
8
|
return method.to_s
|
9
|
-
end
|
10
|
-
|
9
|
+
end
|
10
|
+
|
11
11
|
# Returns a recursive file glob string for the passed in string
|
12
12
|
def file(glob)
|
13
13
|
"**/#{glob}"
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# Returns an extension glob string for passed in string
|
17
17
|
def extension(glob)
|
18
18
|
"*.#{glob}"
|
@@ -22,7 +22,7 @@ module Conveyor
|
|
22
22
|
def any
|
23
23
|
'*'
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
# Returns a list of files that have the same basename but different extension
|
27
27
|
# in the same directory
|
28
28
|
def like(name)
|
@@ -34,7 +34,7 @@ module Conveyor
|
|
34
34
|
def filename
|
35
35
|
@filename
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Which directories to watch for file change events.
|
39
39
|
def watch(*args, &block)
|
40
40
|
yield
|
@@ -44,42 +44,49 @@ module Conveyor
|
|
44
44
|
def match(glob, &block)
|
45
45
|
yield @filename
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# Run the system sync command
|
49
49
|
def sync
|
50
50
|
run 'sync', :quiet => true
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
# Change current working directory, optionally takes a block
|
54
54
|
# NOTE: Consider removing this as it can cause problems with threaded workers
|
55
55
|
def chdir(dir, &block)
|
56
56
|
Dir.chdir(File.expand_path(dir), &block)
|
57
57
|
end
|
58
|
-
|
59
|
-
# Run the system command, and make sure that any errors are caught
|
58
|
+
|
59
|
+
# Run the system command, and make sure that any errors are caught
|
60
60
|
# up the status change
|
61
|
-
def run(*
|
62
|
-
opts =
|
61
|
+
def run(*params)
|
62
|
+
opts = params.extract_options!
|
63
|
+
command = Array.wrap(params).join(' ')
|
64
|
+
info command unless opts[:quiet]
|
65
|
+
|
63
66
|
begin
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
cmdrunner = Mixlib::ShellOut.new(command, timeout: Conveyor::Foreman.instance.config[:command_timeout] || 600)
|
68
|
+
cmdrunner.run_command()
|
69
|
+
|
70
|
+
info cmdrunner.stdout.chomp unless cmdrunner.stdout.chomp.length == 0
|
71
|
+
|
72
|
+
if cmdrunner.error!
|
73
|
+
error "Error running: `#{command}`", cmdrunner.stderr.chomp
|
74
|
+
@status.fail!
|
75
|
+
else
|
76
|
+
if cmdrunner.stderr.chomp.length > 0
|
69
77
|
warning "Error output recieved, but no error code recieved"
|
70
|
-
warning
|
78
|
+
warning cmdrunner.stderr.chomp
|
71
79
|
end
|
72
|
-
else
|
73
|
-
error "Error running: `#{cmd.join(' ')}`", err.chomp
|
74
|
-
@status.fail!
|
75
80
|
end
|
76
|
-
|
77
|
-
return
|
81
|
+
|
82
|
+
return !cmdrunner.error!
|
83
|
+
rescue Mixlib::ShellOut::CommandTimeout => e
|
84
|
+
error e.class, "Timeout running: #{command}"
|
78
85
|
rescue => e
|
79
86
|
error e.class, e.message, e.backtrace.join("\n")
|
80
87
|
end
|
81
88
|
end
|
82
|
-
|
89
|
+
|
83
90
|
# Deletes passed in files
|
84
91
|
def delete(files)
|
85
92
|
# sync before we delete
|
@@ -90,10 +97,10 @@ module Conveyor
|
|
90
97
|
error "#{f} wasn't removed" if File.exists?(f)
|
91
98
|
end
|
92
99
|
end
|
93
|
-
|
100
|
+
|
94
101
|
# Create a new directory
|
95
102
|
def mkdir(dir)
|
96
|
-
FileUtils.mkdir_p(File.expand_path(dir))
|
103
|
+
FileUtils.mkdir_p(File.expand_path(dir))
|
97
104
|
@status.fail! unless File.exists?(File.expand_path(dir))
|
98
105
|
end
|
99
106
|
|
@@ -101,22 +108,22 @@ module Conveyor
|
|
101
108
|
def copy(src = [], dest = nil)
|
102
109
|
destination = dest unless dest.nil?
|
103
110
|
source = src unless src.empty?
|
104
|
-
|
111
|
+
|
105
112
|
if source && destination
|
106
113
|
verified_copy(source, destination)
|
107
|
-
end
|
114
|
+
end
|
108
115
|
end
|
109
|
-
|
116
|
+
|
110
117
|
# Move files to destination
|
111
118
|
def move(src=[], dest = nil)
|
112
119
|
destination = dest unless dest.nil?
|
113
120
|
source = src unless src.empty?
|
114
|
-
|
121
|
+
|
115
122
|
if source && destination
|
116
123
|
verified_move(source, destination)
|
117
124
|
end
|
118
125
|
end
|
119
|
-
|
126
|
+
|
120
127
|
# Scp files to destination
|
121
128
|
# See: man scp
|
122
129
|
def scp(src, dest)
|
@@ -124,4 +131,4 @@ module Conveyor
|
|
124
131
|
end
|
125
132
|
end
|
126
133
|
end
|
127
|
-
end
|
134
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gina-conveyor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.5.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mixlib-shellout
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.2.1
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.2.1
|
125
139
|
description: Conveyor is used for shuffling data around
|
126
140
|
email:
|
127
141
|
- will@gina.alaska.edu
|