Sha256: 3aae1aea50c2356cb66016ec09bb07b4edefd9409074962cacbd403b259ceceb

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

require 'asir/transport'

module Asir
  class Transport
    # Conduit service support.
    module Conduit
      def start_conduit! options = nil
        opts = { :fork => true }
        opts.update(options) if options
        _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
        else
          _start_conduit!
        end
        self
      end

      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)
          ::Process.waitpid @conduit_pid
          # File.unlink @redis_conf
        end
        self
      ensure
        @conduit_pid = nil
      end

      def _start_conduit!
        raise Error::SubclassResponsibility
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asir-1.1.5 lib/asir/transport/conduit.rb
asir-1.1.4 lib/asir/transport/conduit.rb
asir-1.1.3 lib/asir/transport/conduit.rb
asir-1.1.2 lib/asir/transport/conduit.rb
asir-1.1.1 lib/asir/transport/conduit.rb
asir-1.1.0 lib/asir/transport/conduit.rb
asir-1.0.8 lib/asir/transport/conduit.rb
asir-1.0.7 lib/asir/transport/conduit.rb
asir-1.0.6 lib/asir/transport/conduit.rb
asir-1.0.5 lib/asir/transport/conduit.rb
asir-1.0.4 lib/asir/transport/conduit.rb