Closed yn closed 10 years ago
I have the same behaviour.
It seems the Daemons.run_proc
-call hangs when starting and stopping the daemon proc.
It doesn't matter what code the block contains (i.e. if I replace the RubyDNS::run_server
with just loop { sleep 1 }
I still see the same behaviour).
Within the daemons
gem I tracked it down to call_as_daemon
inside lib/daemons/daemonize.rb
which looks like this:
def call_as_daemon(block, logfile_name = nil, app_name = nil)
rd, wr = IO.pipe
if tmppid = safefork
# parent
wr.close
pid = rd.read.to_i // <-- THIS LINE IS BLOCKING
rd.close
[...]
else
# child
rd.close
[...]
wr.write Process.pid
wr.close
[...]
end
so basically the child process sends its PID through a pipe to the parent which reads it.
While debugging I noticed that the PID is sent into the pipe, but never received in the parent. So that rd.read
-call hangs.
I can only reproduce this behaviour within the "vagrant ruby", by running bundle exec vagrant up
. If I run the same code in my local ruby environment it doesn't hang.
Can anyone confirm this behaviour? I wanted to start using vagrant-dns
just now, anyone using it for longer and can confirm this bug?
I noticed that the Gemfile.lock
is gitignored. Since the gemspec
uses git ls-files
to populate gem.files
I assume the gem doesn't include a lock-file. Therefore probably the newest version will be installed for all gems when installing the plugin?
Hi,
I'm just experiencing the same issue. As a workaround (so that your vagrant up
won't hang) you can disable auto run in your Vagrantfile
:
Vagrant.configure("2") do |config|
#....
VagrantDNS::Config.auto_run = false
# ...
end
and start/stop manually vagrant dns --start
/ vagrant dns --stop
. I had to manually kill the running dns process: kill $(cat ~/.vagrant.d/tmp/dns/daemon/vagrant-dns.pid)
in order to get star/stop working correctly.
Also, I reinstalled all my vagrant plugins by deleting ~/.vagrant.d/gems
and vagrant plugin install
all the things. I'm not sure if this made any differences, it was my first attempt to get daemons working correctly.
My suspicion first was that some gem-dependencies is responsible for this.
Any other ideas?
Unfortunately I'm not too acquainted with bundler
nor vagrant
, which might be relevant since the problem only occurs in when running vagrant with bundle exec vagrant up
, not when invoked from my local ruby as a normal script.
I've isolated the problem a bit. It seems the Process.waitpid(tmppid)
in the parent process hangs.
I opened an issue with vagrant
asking for help: https://github.com/mitchellh/vagrant/issues/2756
A fix for this has landed in vagrant: https://github.com/mitchellh/vagrant/issues/2756 I think this can be closed.
This is resolved with the now released vagrant 1.5.
I configured vagrant-dns according to instructions, but when bringing my machine up, the boot process hangs (the machine comes up successfully however, and DNS queries to it resolve).
This hang started happening only when I installed vagrant-dns, so I am thinking it is the culprit. Here's the behavior I've seen:
If I have a vagrant-dns server already running, the "vagrant up" process tries to kill it (I see messages from vagrant-dns to that effect). Then, I see in my process list that a new vagrant-dns is up. Then, everything hangs. If I press Ctrl-C, this is what I get: