Module: Asir::Transport::Conduit
- Defined in:
- lib/asir/transport/conduit.rb
Overview
Conduit service support.
Instance Attribute Summary collapse
-
#conduit_options ⇒ Object
Returns the value of attribute conduit_options.
-
#conduit_pid ⇒ Object
Returns the value of attribute conduit_pid.
Instance Method Summary collapse
- #_start_conduit! ⇒ Object
- #start_conduit!(options = nil) ⇒ Object
- #stop_conduit!(opts = nil) ⇒ Object
Instance Attribute Details
#conduit_options ⇒ Object
Returns the value of attribute conduit_options.
7 8 9 |
# File 'lib/asir/transport/conduit.rb', line 7 def @conduit_options end |
#conduit_pid ⇒ Object
Returns the value of attribute conduit_pid.
7 8 9 |
# File 'lib/asir/transport/conduit.rb', line 7 def conduit_pid @conduit_pid end |
Instance Method Details
#_start_conduit! ⇒ Object
50 51 52 |
# File 'lib/asir/transport/conduit.rb', line 50 def _start_conduit! raise Error::SubclassResponsibility end |
#start_conduit!(options = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/asir/transport/conduit.rb', line 8 def start_conduit! = nil opts = { :fork => true } opts.update() if @conduit_options = opts _log { "start_conduit! #{self}" } if @verbose >= 1 in_fork = opts[:fork] raise "already running #{@conduit_pid} #{@conduit_cmd}" if @conduit_pid if in_fork @conduit_pid = ::Process.fork do _log { "start_conduit! #{self} starting pid=#{$$.inspect}" } if @verbose >= 2 _start_conduit! raise "Could not exec" end _log { "start_conduit! #{self} started pid=#{@conduit_pid.inspect}" } if @verbose >= 2 if pid_file = @conduit_options[:pid_file] File.open(pid_file, "w") { | fh | fh.puts @conduit_pid } end else _start_conduit! end self end |
#stop_conduit!(opts = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/asir/transport/conduit.rb', line 38 def stop_conduit! opts = nil if conduit_pid _log { "stop_conduit! #{self} pid=#{@conduit_pid.inspect}" } if @verbose >= 1 ::Process.kill( (opts && opts[:signal]) || 'TERM', @conduit_pid) ::File.unlink(pid_file) rescue nil if pid_file ::Process.waitpid @conduit_pid end self ensure @conduit_pid = nil end |