gorgon 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/Gemfile.lock +9 -9
- data/README.md +33 -9
- data/bin/gorgon +9 -0
- data/gorgon.json.sample +29 -0
- data/gorgon_listener.json.sample +8 -0
- data/lib/gorgon/colors.rb +1 -0
- data/lib/gorgon/crash_reporter.rb +19 -0
- data/lib/gorgon/gem_command_handler.rb +46 -0
- data/lib/gorgon/gem_service.rb +77 -0
- data/lib/gorgon/job_state.rb +4 -4
- data/lib/gorgon/listener.rb +26 -21
- data/lib/gorgon/originator_protocol.rb +9 -8
- data/lib/gorgon/ping_service.rb +2 -2
- data/lib/gorgon/pipe_forker.rb +22 -0
- data/lib/gorgon/source_tree_syncer.rb +2 -1
- data/lib/gorgon/version.rb +1 -1
- data/lib/gorgon/worker.rb +64 -30
- data/lib/gorgon/worker_manager.rb +42 -12
- data/spec/crash_reporter_spec.rb +46 -0
- data/spec/gem_command_handler_spec.rb +84 -0
- data/spec/gem_service_spec.rb +74 -0
- data/spec/job_state_spec.rb +0 -7
- data/spec/listener_spec.rb +37 -19
- data/spec/originator_protocol_spec.rb +12 -9
- data/spec/ping_service_spec.rb +3 -3
- data/spec/pipe_forker_spec.rb +53 -0
- data/spec/worker_manager_spec.rb +34 -5
- data/spec/worker_spec.rb +63 -1
- metadata +12 -4
- data/lib/gorgon/pipe_manager.rb +0 -55
- data/lib/gorgon/worker_watcher.rb +0 -22
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorgon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-
|
16
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rspec
|
@@ -208,13 +208,18 @@ files:
|
|
208
208
|
- Rakefile
|
209
209
|
- bin/gorgon
|
210
210
|
- gorgon.gemspec
|
211
|
+
- gorgon.json.sample
|
212
|
+
- gorgon_listener.json.sample
|
211
213
|
- lib/gorgon.rb
|
212
214
|
- lib/gorgon/amqp_service.rb
|
213
215
|
- lib/gorgon/callback_handler.rb
|
214
216
|
- lib/gorgon/colors.rb
|
215
217
|
- lib/gorgon/configuration.rb
|
218
|
+
- lib/gorgon/crash_reporter.rb
|
216
219
|
- lib/gorgon/failures_printer.rb
|
217
220
|
- lib/gorgon/g_logger.rb
|
221
|
+
- lib/gorgon/gem_command_handler.rb
|
222
|
+
- lib/gorgon/gem_service.rb
|
218
223
|
- lib/gorgon/host_state.rb
|
219
224
|
- lib/gorgon/job.rb
|
220
225
|
- lib/gorgon/job_definition.rb
|
@@ -224,16 +229,18 @@ files:
|
|
224
229
|
- lib/gorgon/originator_logger.rb
|
225
230
|
- lib/gorgon/originator_protocol.rb
|
226
231
|
- lib/gorgon/ping_service.rb
|
227
|
-
- lib/gorgon/
|
232
|
+
- lib/gorgon/pipe_forker.rb
|
228
233
|
- lib/gorgon/progress_bar_view.rb
|
229
234
|
- lib/gorgon/source_tree_syncer.rb
|
230
235
|
- lib/gorgon/testunit_runner.rb
|
231
236
|
- lib/gorgon/version.rb
|
232
237
|
- lib/gorgon/worker.rb
|
233
238
|
- lib/gorgon/worker_manager.rb
|
234
|
-
- lib/gorgon/worker_watcher.rb
|
235
239
|
- spec/callback_handler_spec.rb
|
240
|
+
- spec/crash_reporter_spec.rb
|
236
241
|
- spec/failures_printer_spec.rb
|
242
|
+
- spec/gem_command_handler_spec.rb
|
243
|
+
- spec/gem_service_spec.rb
|
237
244
|
- spec/host_state_spec.rb
|
238
245
|
- spec/job_definition_spec.rb
|
239
246
|
- spec/job_state_spec.rb
|
@@ -242,6 +249,7 @@ files:
|
|
242
249
|
- spec/originator_protocol_spec.rb
|
243
250
|
- spec/originator_spec.rb
|
244
251
|
- spec/ping_service_spec.rb
|
252
|
+
- spec/pipe_forker_spec.rb
|
245
253
|
- spec/progress_bar_view_spec.rb
|
246
254
|
- spec/source_tree_syncer_spec.rb
|
247
255
|
- spec/worker_manager_spec.rb
|
data/lib/gorgon/pipe_manager.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module PipeManager
|
2
|
-
private
|
3
|
-
|
4
|
-
def pipe_fork_worker
|
5
|
-
pid = fork do
|
6
|
-
bind_to_fifos
|
7
|
-
worker = Worker.build(@config)
|
8
|
-
worker.work
|
9
|
-
exit
|
10
|
-
end
|
11
|
-
|
12
|
-
fifo_in, fifo_out, fifo_err = wait_for_fifos pid
|
13
|
-
|
14
|
-
pipe_in = File.open(fifo_in, "w")
|
15
|
-
pipe_out = File.open(fifo_out)
|
16
|
-
pipe_err = File.open(fifo_err)
|
17
|
-
|
18
|
-
return pid, pipe_in, pipe_out, pipe_err
|
19
|
-
end
|
20
|
-
|
21
|
-
def pipe_file pid, stream
|
22
|
-
"#{pid}_#{stream}.pipe"
|
23
|
-
end
|
24
|
-
|
25
|
-
def bind_to_fifos
|
26
|
-
fifo_in = pipe_file $$, "in"
|
27
|
-
fifo_out = pipe_file $$, "out"
|
28
|
-
fifo_err = pipe_file $$, "err"
|
29
|
-
|
30
|
-
system("mkfifo '#{fifo_in}'")
|
31
|
-
system("mkfifo '#{fifo_out}'")
|
32
|
-
system("mkfifo '#{fifo_err}'")
|
33
|
-
|
34
|
-
@@old_in = $stdin
|
35
|
-
$stdin = File.open(fifo_in)
|
36
|
-
|
37
|
-
@@old_out = $stdout
|
38
|
-
$stdout = File.open(fifo_out, "w")
|
39
|
-
|
40
|
-
@@old_err = $stderr
|
41
|
-
$stderr = File.open(fifo_err, "w")
|
42
|
-
end
|
43
|
-
|
44
|
-
def wait_for_fifos pid
|
45
|
-
fifo_in = pipe_file pid, "in"
|
46
|
-
fifo_out = pipe_file pid, "out"
|
47
|
-
fifo_err = pipe_file pid, "err"
|
48
|
-
|
49
|
-
while !File.exist?(fifo_in) || !File.exist?(fifo_out) || !File.exist?(fifo_err) do
|
50
|
-
sleep 0.01
|
51
|
-
end
|
52
|
-
|
53
|
-
return fifo_in, fifo_out, fifo_err
|
54
|
-
end
|
55
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'eventmachine'
|
2
|
-
require 'socket'
|
3
|
-
|
4
|
-
class WorkerWatcher < EventMachine::ProcessWatch
|
5
|
-
def initialize(options = {})
|
6
|
-
@pid = options[:pid]
|
7
|
-
@stdout = options[:stdout]
|
8
|
-
@stderr = options[:stderr]
|
9
|
-
@reply_exchange = options[:reply_exchange]
|
10
|
-
end
|
11
|
-
|
12
|
-
def process_exited
|
13
|
-
ignored, status = Process::waitpid2 @pid
|
14
|
-
if status.exitstatus != 0
|
15
|
-
reply = {:type => :crash,
|
16
|
-
:hostname => Socket.gethostname,
|
17
|
-
:stdout => @stdout.read,
|
18
|
-
:stderr => @stderr.read}
|
19
|
-
@reply_exchange.publish(Yajl::Encoder.encode(reply))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|