Coder Social home page Coder Social logo

c.stop hangs about ruby-lxc HOT 5 CLOSED

lxc avatar lxc commented on May 23, 2024
c.stop hangs

from ruby-lxc.

Comments (5)

andrenth avatar andrenth commented on May 23, 2024

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

from ruby-lxc.

bararchy avatar bararchy commented on May 23, 2024

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 [email protected] 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:
#27 (comment)

from ruby-lxc.

andrenth avatar andrenth commented on May 23, 2024

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.

from ruby-lxc.

andrenth avatar andrenth commented on May 23, 2024

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.

from ruby-lxc.

bararchy avatar bararchy commented on May 23, 2024

Thanks for the explanation and fast responses,
Setting wait:true as default is a smart move, thanks for this gem :)

from ruby-lxc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.