Closed bararchy closed 9 years ago
Hello Bar
I can't reproduce this. It works fine for me as shown below:
irb(main):001:0> require 'lxc'
=> true
irb(main):002:0> c = LXC::Container.new('ruby')
=> #<LXC::Container:0x00000001da0920>
irb(main):003:0> c.create('ubuntu')
Checking cache download in /var/cache/lxc/trusty/rootfs-amd64 ...
Copy /var/cache/lxc/trusty/rootfs-amd64 to /var/lib/lxc/ruby/rootfs ...
Copying rootfs to /var/lib/lxc/ruby/rootfs ...
...
=> #<LXC::Container:0x00000001da0920>
irb(main):004:0> c.start
=> #<LXC::Container:0x00000001da0920>
irb(main):005:0> c.stop
=> #<LXC::Container:0x00000001da0920>
irb(main):006:0>
Does it work for you when you use the lxc command line tools?
# lxc-create -n test -t ubuntu
# lxc-start -n test
# lxc-stop -n test
Hi , When using the command line tool the stop works, to reproduce try to initiate a command as in LXC.command and ls /tmp or something along those lines.
Sent from Blue Mail
On Dec 18, 2014, 14:53, at 14:53, Andre Nathan notifications@github.com wrote:
Hello Bar
I can't reproduce this. It works fine for me as shown below:
irb(main):001:0> require 'lxc' => true irb(main):002:0> c = LXC::Container.new('ruby') => #<LXC::Container:0x00000001da0920> irb(main):003:0> c.create('ubuntu') Checking cache download in /var/cache/lxc/trusty/rootfs-amd64 ... Copy /var/cache/lxc/trusty/rootfs-amd64 to /var/lib/lxc/ruby/rootfs ... Copying rootfs to /var/lib/lxc/ruby/rootfs ... ... => #<LXC::Container:0x00000001da0920> irb(main):004:0> c.start => #<LXC::Container:0x00000001da0920> irb(main):005:0> c.stop => #<LXC::Container:0x00000001da0920> irb(main):006:0>
Does it work for you when you use the lxc command line tools?
# lxc-create -n test -t ubuntu # lxc-start -n test # lxc-stop -n test
Reply to this email directly or view it on GitHub: https://github.com/lxc/ruby-lxc/issues/27#issuecomment-67481746
I managed to reproduce the freeze after using attach.
As a workaround, you can use c.attach(wait: true) { ... }
and then c.stop
won't freeze.
I'll look into what's going on when wait
is false
.
OK, I remembered how this API is supposed to work. You either pass wait: true
or you have to wait for the child yourself:
irb(main):001:0> require 'lxc'
=> true
irb(main):002:0> c = LXC::Container.new('ruby')
=> #<LXC::Container:0x00000001206ba0>
irb(main):003:0> c.start
=> #<LXC::Container:0x00000001206ba0>
irb(main):004:0> pid = c.attach {}
=> 29503
irb(main):005:0> Process.wait(pid)
=> 29503
irb(main):006:0> c.stop
=> #<LXC::Container:0x00000001206ba0>
I guess the motivation for this is the possibility to call attach multiple times without having to wait for each child process to finish sequentially (ie, call Process.waitall
at the end of the script, before calling LXC::Container#stop
).
On the other hand, it seems to me that the most common use-case is to have wait: true
, so I think I'll change the default value of this option. This would change the API though, so probably it would have to wait (no pun intended) for a new major version release.
Thanks for the explanation and fast responses, Setting wait:true as default is a smart move, thanks for this gem :)
So, this is my code:
But, it hangs on c.stop and never reaches "puts "Clearing config for container #{c.name}...""
Manually trying to stop it shows: