ysbaddaden / prax

Rack proxy server for development
http://ysbaddaden.github.io/prax/
Other
475 stars 49 forks source link

Failing to spawn apps on unstable branch #61

Closed suan closed 10 years ago

suan commented 10 years ago

I have a stock-generated rails app which works fine on master but on unstable I get this. Any ideas? All my apps are seeing this behavior on unstable. I'm running Debian Wheezy

$ PRAX_DEBUG=1 prax start --foreground
I, [2014-02-03T19:35:23.204300 #20031]  INFO -- : Prax is ready to receive connections on :20559.
I, [2014-02-03T19:35:31.397758 #20031]  INFO -- : Spawning application 'testy' [/home/vagrant/Projects/testy]
D, [2014-02-03T19:35:31.397903 #20031] DEBUG -- : exec bundle exec /opt/prax/bin/racker --server /home/vagrant/.prax/_sockets/testy.sock
E, [2014-02-03T19:35:31.400867 #20031] ERROR -- : Errno::ENOENT:No such file or directory - exec bundle exec /opt/prax/bin/racker --server /home/vagrant/.prax/_sockets/testy.sock
  /opt/prax/lib/prax/application.rb:97:in `spawn'
  /opt/prax/lib/prax/application.rb:97:in `spawn'
  /opt/prax/lib/prax/application.rb:17:in `start'
  /opt/prax/lib/prax/spawner.rb:49:in `spawn'
  /opt/prax/lib/prax/spawner.rb:23:in `block in get'
  <internal:prelude>:10:in `synchronize'
  /opt/prax/lib/prax/spawner.rb:17:in `get'
  /opt/prax/lib/prax/handler.rb:47:in `app'
  /opt/prax/lib/prax/handler.rb:43:in `connection'
  /opt/prax/lib/prax/handler.rb:21:in `handle'
  /opt/prax/lib/prax.rb:19:in `perform'
  /opt/prax/lib/prax/microworker.rb:84:in `block in work'
  /opt/prax/lib/prax/microworker.rb:77:in `each'
  /opt/prax/lib/prax/microworker.rb:77:in `work'
  /opt/prax/lib/prax/microworker.rb:63:in `block in spawn'
I, [2014-02-03T19:35:31.401235 #20031]  INFO -- : Respawning failed worker
/opt/prax/lib/prax/application.rb:97:in `spawn': No such file or directory - exec bundle exec /opt/prax/bin/racker --server /home/vagrant/.prax/_sockets/testy.sock (Errno::ENOENT)
    from /opt/prax/lib/prax/application.rb:97:in `spawn'
    from /opt/prax/lib/prax/application.rb:17:in `start'
    from /opt/prax/lib/prax/spawner.rb:49:in `spawn'
    from /opt/prax/lib/prax/spawner.rb:23:in `block in get'
    from <internal:prelude>:10:in `synchronize'
    from /opt/prax/lib/prax/spawner.rb:17:in `get'
    from /opt/prax/lib/prax/handler.rb:47:in `app'
    from /opt/prax/lib/prax/handler.rb:43:in `connection'
    from /opt/prax/lib/prax/handler.rb:21:in `handle'
    from /opt/prax/lib/prax.rb:19:in `perform'
    from /opt/prax/lib/prax/microworker.rb:84:in `block in work'
    from /opt/prax/lib/prax/microworker.rb:77:in `each'
    from /opt/prax/lib/prax/microworker.rb:77:in `work'
    from /opt/prax/lib/prax/microworker.rb:63:in `block in spawn'
ysbaddaden commented 10 years ago

Which ruby version are you running? I never saw this bug.

It see it fails here: https://github.com/ysbaddaden/prax/blob/unstable/lib/prax/application.rb#L97

Maybe it's Process.spawn or maybe it's related to realpath or log_path or socket_path?

suan commented 10 years ago

Hmmm, very interesting. The problem seems to be the combination of Process.spawn and exec. On both my Linux VM and Mac natively, when I do Process.spawn({}, 'exec <any command (such as ls)>') in a Ruby 1.9.3 irb, I get a "Errno::ENOENT: No such file or directory" error.

However, I if I do the same in a 2.0.x irb, it works. I bet you're testing with Ruby 2.0 and up?

What was the intent behind having exec at the beginning of the rackup command? I removed it and everything seems to work fine...

ysbaddaden commented 10 years ago

Process.spawn creates a shell, and I'm using exec to replace it for the Racker process, otherwise Prax::Monitor won't autokill instances: it kills the shell which leaves an orphaned Racker Process, when we wanted to kill the Racker process itself.

I guess I'll have to find another solution to support Ruby 1.9. Thanks for reporting!

ysbaddaden commented 10 years ago

Fixed in 55d49a0c0611c9fdaa2c7ab37f2e9e239e9a3d01