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
53 54 55 |
# File 'lib/asir/transport/conduit.rb', line 53 def _start_conduit! raise Error::SubclassResponsibility end |
#start_conduit!(options = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/asir/transport/conduit.rb', line 9 def start_conduit! = nil opts = @conduit_options ||= {} opts.update(:fork => true) opts.update() if _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 || EMPTY_HASH)[:pid_file] File.open(pid_file, "w") { | fh | fh.puts @conduit_pid } end else _start_conduit! end self end |
#stop_conduit!(opts = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/asir/transport/conduit.rb', line 39 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) if pid_file = (@conduit_options || EMPTY_HASH)[:pid_file] ::File.unlink(pid_file) rescue nil end ::Process.waitpid @conduit_pid end self ensure @conduit_pid = nil end |