Sha256: 5229c94e837f7646658454d78005de347696f8872bc2b65b3c5a8917308c90bf

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

require 'socket'
require 'pathname'
require 'vx/container_connector'

module Vx
  module Worker

    StartConnector = Struct.new(:app) do

      include Helper::Config
      include Helper::Instrument

      def call(env)
        options = config.connector_options
        env.connector = ContainerConnector.lookup(config.run, options)

        instrument("starting_container", env.job.instrumentation)

        env.connector.start do |spawner|
          env.job.add_to_output "using #{Socket.gethostname}##{spawner.id}\n"

          instrument("container_started", env.job.instrumentation.merge(container: spawner.id))

          begin
            env.spawner = spawner
            app.call env
          ensure
            env.spawner = spawner
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vx-worker-0.3.0.pre1 lib/vx/worker/middlewares/start_connector.rb