lib/elecksee/ephemeral.rb in elecksee-1.0.10 vs lib/elecksee/ephemeral.rb in elecksee-1.0.12
- old
+ new
@@ -51,14 +51,14 @@
@name = File.basename(@path)
@hostname = @name.gsub(%r{[^A-Za-z0-9\-]}, '')
@ephemeral_binds = []
@lxc = nil
end
-
+
def register_traps
%w(TERM INT QUIT).each do |sig|
- Signal.trap(sig){ cleanup }
+ Signal.trap(sig){ cleanup && raise }
end
end
def cli_output
if(cli)
@@ -69,21 +69,26 @@
def start_action
begin
lxc.start
if(ephemeral_command)
+ lxc.wait_for_state(:running)
lxc.container_command(ephemeral_command)
else
cli_output
lxc.wait_for_state(:stopped)
end
ensure
cleanup
end
true
end
-
+
+ def create!
+ setup
+ end
+
def start!(*args)
register_traps
setup
if(daemon)
if(args.include?(:fork))
@@ -112,11 +117,11 @@
false
end
end
private
-
+
def setup
create
build_overlay
update_naming
discover_binds
@@ -136,17 +141,17 @@
:target => lxc.path.join('rootfs').to_path,
:overlay_type => union
)
@ephemeral_overlay.mount
end
-
+
def create
Dir.glob(File.join(lxc_dir, original, '*')).each do |o_path|
next unless File.file?(o_path)
command("cp #{o_path} #{File.join(path, File.basename(o_path))}", :sudo => true)
end
@lxc = Lxc.new(name)
- command("mkdir -p '#{lxc.path.join('rootfs')}'", :sudo => true)
+ command("mkdir -p #{lxc.path.join('rootfs')}", :sudo => true)
update_net_hwaddr
end
# TODO: Discovered binds for ephemeral are all tmpfs for now.
# TODO: We should default to overlay mount, make virt dev optional