openshift/origin-server — pull request #4440 by mfojtik (2014-01-09 14:18:53+00:00)
Title: Bug 984867 - Replace PassengerSpawnIPAddress with bash function

The `PassengerSpawnIPAddress` configuration directive that should 'pre-spawn' the application when the Ruby cartridge starts is currently broken as it is doing the request against 127.0.0.1 instead of configured `OPENSHIFT_RUBY_IP`. This is due to a 'recent' change to passenger when they dropped support for this directive and replaced it by this code:

```
def connect
TCPSocket.new('127.0.0.1', request_port)
end
```

This issue is hard to reproduce on DEVENV because we have an HTTPD listening on that address, so the request succeed even it is 'waking up' a wrong application... In this case, no error is printed into application error_log. However in PROD, we don't have any server listening for these request and for that users can see this error message when the application is being started:

```
[Thu Jan 09 08:32:25 2014] [notice] Apache/2.2.22 (Unix) Phusion_Passenger/3.0.21 configured -- resuming normal operations
/opt/rh/ruby193/root/usr/share/gems/gems/passenger-3.0.21/helper-scripts/prespawn:105:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /opt/rh/ruby193/root/usr/share/gems/gems/passenger-3.0.21/helper-scripts/prespawn:105:in `new'
```

I think the prespawn is important to preserve the user-experience as the users might get 503 after we say into console that the application is 'started'.
I replaced the PassengerSpawnIPAddress logic with a simple curl function that will do the same HEAD request.