Module: Zeus
- Defined in:
- lib/zeus.rb,
lib/zeus/m.rb,
lib/zeus/rails.rb,
lib/zeus/load_tracking.rb,
lib/zeus/m/test_method.rb,
lib/zeus/m/test_collection.rb
Defined Under Namespace
Modules: M Classes: LoadTracking, Plan, Rails
Class Attribute Summary collapse
-
.dummy_tty ⇒ Object
Returns the value of attribute dummy_tty.
-
.master_socket ⇒ Object
Returns the value of attribute master_socket.
-
.plan ⇒ Object
Returns the value of attribute plan.
Class Method Summary collapse
- .go(identifier = :boot) ⇒ Object
-
.setup_dummy_tty! ⇒ Object
this is totally asinine, but readline gets super confused when it’s required at a time when stdin or stdout is not connected to a TTY, no matter what we do to tell it otherwise later.
- .setup_master_socket! ⇒ Object
Class Attribute Details
.dummy_tty ⇒ Object
Returns the value of attribute dummy_tty.
14 15 16 |
# File 'lib/zeus.rb', line 14 def dummy_tty @dummy_tty end |
.master_socket ⇒ Object
Returns the value of attribute master_socket.
14 15 16 |
# File 'lib/zeus.rb', line 14 def master_socket @master_socket end |
.plan ⇒ Object
Returns the value of attribute plan.
14 15 16 |
# File 'lib/zeus.rb', line 14 def plan @plan end |
Class Method Details
.go(identifier = :boot) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/zeus.rb', line 39 def go(identifier=:boot) $0 = "zeus slave: #{identifier}" setup_dummy_tty! master = setup_master_socket! # I need to give the master a way to talk to me exclusively local, remote = UNIXSocket.pair(Socket::SOCK_STREAM) master.send_io(remote) # Now I need to tell the master about my PID and ID local.write "P:#{Process.pid}:#{identifier}\0" # Now we run the action and report its success/fail status to the master. features = Zeus::LoadTracking.features_loaded_by { run_action(local, identifier) } # the master wants to know about the files that running the action caused us to load. Thread.new { notify_features(local, features) } # We are now 'connected'. From this point, we may receive requests to fork. loop do = local.recv(1024) .split("\0").each do |new_identifier| new_identifier =~ /^(.):(.*)/ code, ident = $1, $2 if code == "S" fork { plan.after_fork ; go(ident.to_sym) } else fork { plan.after_fork ; command(ident.to_sym, local) } end end end end |
.setup_dummy_tty! ⇒ Object
this is totally asinine, but readline gets super confused when it’s required at a time when stdin or stdout is not connected to a TTY, no matter what we do to tell it otherwise later. So we create a dummy TTY in case readline is required.
Yup.
22 23 24 25 26 27 28 29 30 |
# File 'lib/zeus.rb', line 22 def setup_dummy_tty! return if self.dummy_tty master, self.dummy_tty = PTY.open Thread.new { loop { master.read(1024) } } STDIN.reopen(dummy_tty) STDOUT.reopen(dummy_tty) end |
.setup_master_socket! ⇒ Object
32 33 34 35 36 37 |
# File 'lib/zeus.rb', line 32 def setup_master_socket! return master_socket if master_socket fd = ENV['ZEUS_MASTER_FD'].to_i self.master_socket = UNIXSocket.for_fd(fd) end |