zeus 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- data/build/zeus-darwin-amd64 +0 -0
- data/build/zeus-linux-386 +0 -0
- data/build/zeus-linux-amd64 +0 -0
- data/lib/zeus.rb +49 -2
- metadata +2 -2
data/build/zeus-darwin-amd64
CHANGED
Binary file
|
data/build/zeus-linux-386
CHANGED
Binary file
|
data/build/zeus-linux-amd64
CHANGED
Binary file
|
data/lib/zeus.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'socket'
|
2
3
|
require 'json'
|
4
|
+
require 'pty'
|
3
5
|
|
4
6
|
require 'zeus/load_tracking'
|
5
7
|
|
@@ -10,8 +12,26 @@ module Zeus
|
|
10
12
|
|
11
13
|
class << self
|
12
14
|
attr_accessor :plan
|
15
|
+
attr_accessor :dummy_tty
|
16
|
+
|
17
|
+
# this is totally asinine, but readline gets super confused when it's
|
18
|
+
# required at a time when stdin or stdout is not connected to a TTY,
|
19
|
+
# no matter what we do to tell it otherwise later. So we create a dummy
|
20
|
+
# TTY in case readline is required.
|
21
|
+
#
|
22
|
+
# Yup.
|
23
|
+
def setup_dummy_tty!
|
24
|
+
return if self.dummy_tty
|
25
|
+
master, self.dummy_tty = PTY.open
|
26
|
+
Thread.new {
|
27
|
+
loop { master.read(1024) }
|
28
|
+
}
|
29
|
+
STDIN.reopen(dummy_tty)
|
30
|
+
STDOUT.reopen(dummy_tty)
|
31
|
+
end
|
13
32
|
|
14
33
|
def go(identifier=:boot)
|
34
|
+
setup_dummy_tty!
|
15
35
|
$0 = "zeus slave: #{identifier}"
|
16
36
|
# okay, so I ahve this FD that I can use to send data to the master.
|
17
37
|
fd = ENV['ZEUS_MASTER_FD'].to_i
|
@@ -58,10 +78,20 @@ module Zeus
|
|
58
78
|
remote.close
|
59
79
|
sock.close
|
60
80
|
|
61
|
-
|
62
|
-
|
81
|
+
begin
|
82
|
+
pid_and_arguments = local.recv(1024)
|
83
|
+
pid_and_arguments.chomp!("\0")
|
84
|
+
# pid_and_arguments.force_encoding("ASCII-8BIT")
|
85
|
+
File.open("b.log","a"){|f|f.puts "PA#{pid_and_arguments}" }
|
86
|
+
pid_and_arguments =~ /(.*?):(.*)/
|
87
|
+
client_pid, arguments = $1.to_i, $2
|
88
|
+
arguments.chomp!("\0")
|
89
|
+
rescue => e
|
90
|
+
File.open("b.log","a"){|f|f.puts e.message ; f.puts e.backtrace}
|
91
|
+
end
|
63
92
|
|
64
93
|
pid = fork {
|
94
|
+
$0 = "zeus command: #{identifier}"
|
65
95
|
plan.after_fork
|
66
96
|
client_terminal = local.recv_io
|
67
97
|
local.write "P:#{Process.pid}:\0"
|
@@ -75,6 +105,8 @@ module Zeus
|
|
75
105
|
plan.send(identifier)
|
76
106
|
}
|
77
107
|
|
108
|
+
kill_command_if_client_quits!(pid, client_pid)
|
109
|
+
|
78
110
|
Process.wait(pid)
|
79
111
|
code = $?.exitstatus || 0
|
80
112
|
|
@@ -83,6 +115,21 @@ module Zeus
|
|
83
115
|
local.close
|
84
116
|
end
|
85
117
|
|
118
|
+
def kill_command_if_client_quits!(command_pid, client_pid)
|
119
|
+
Thread.new {
|
120
|
+
loop {
|
121
|
+
begin
|
122
|
+
File.open("b.log","a"){|f|f.puts "Checking #{client_pid}"}
|
123
|
+
x=Process.kill(0, client_pid)
|
124
|
+
File.open("b.log","a"){|f|f.puts "Checked #{client_pid} and got #{x}"}
|
125
|
+
rescue Errno::ESRCH
|
126
|
+
Process.kill(9, command_pid)
|
127
|
+
end
|
128
|
+
sleep 1
|
129
|
+
}
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
86
133
|
def notify_features(sock, features)
|
87
134
|
features.each do |t|
|
88
135
|
begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: method_source
|