schubergphilis / vagrant-chef-zero

Vagrant Plugin for Chef Zero
Apache License 2.0
91 stars 42 forks source link

Chef Zero Fails to Start - lsof can't find pid #11

Closed harlanbarnes closed 11 years ago

harlanbarnes commented 11 years ago

After I sorted out #10 , it still wouldn't start. It looks like it came down to this line:

pid = %x[ lsof -i tcp:#{port} | grep ruby | awk '{print $2}' ]

For whatever reason, my lsof was setting the "command" to be "chef-zero" instead of ruby. Thus, I was getting this:

[harlan@clay zabbix]$ lsof -i tcp:4000
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
chef-zero 19379 harlan    9u  IPv4 283915      0t0  TCP clay.local:4000 (LISTEN)

which the above line was never finding. So I just did this and it worked:

pid = %x[ lsof -i tcp:#{port} | grep 'chef-zero' | awk '{print $2}' ]

Maybe something like this handles both?

pid = %x[ lsof -i tcp:#{port} | grep -E 'ruby|chef-zero' | awk '{print $2}' ]

Both this and #10 are no big deal. I'm good to go for now. Just a heads up in case anyone else gets this.

andrewgross commented 11 years ago

Interesting. It is pretty fragile way to find the PID, I'll see if I can think of anything better than your suggestion.

andrewgross commented 11 years ago

Copping out for now as scanning through the process list can be maddening and error prone. I will push this change out soon.

andrewgross commented 11 years ago

Fixed in 0.2.5

abathur commented 11 years ago

Andrew--I was looking into what it would take to get this plugin working on Windows. I'm not really familiar with Ruby so I'll spare both of us an attempt at pushing changes. When I was looking into the lsof/PID issue I found an SO question linking this blog post: http://unethicalblogger.com/2011/11/12/popen-can-suck-it.html which may give you a better way to get at the PID using proc.pid.

As an aside to the issue here, downstream I ran into windows compatibility issues with file paths.