Sha256: 4144b011229c71e2dd189fc380a4051fa33fb7c0ea1c18c30a44892507c1ffba
Contents?: true
Size: 952 Bytes
Versions: 5
Compression:
Stored size: 952 Bytes
Contents
require 'tempfile' require 'fileutils' module Vx ; module Lib ; module Container ; class Local include Lib::Container::Instrument autoload :Spawner, File.expand_path("../local/spawner", __FILE__) attr_reader :work_dir def initialize(options = {}) @work_dir = options[:work_dir] || default_work_dir @work_dir = File.expand_path(@work_dir) end def start(&block) instrument( "create", container_type: 'local', container: { work_dir: work_dir }) do FileUtils.rm_rf(work_dir) FileUtils.mkdir_p(work_dir) end begin spawner = Spawner.new(work_dir) yield spawner ensure instrument( "kill", container_type: 'local', container: { work_dir: work_dir }) do FileUtils.mkdir_p(work_dir) end end end private def default_work_dir "#{::Dir.tmpdir}/vx_lib_container_#{::Process.pid}" end end end ; end ; end
Version data entries
5 entries across 5 versions & 1 rubygems