Posted: over 2 years
The error: “Could not spawn process for application /var/deploy/thny/web_head/current: An error occurred while starting up the preloader: it did not write a startup response in time” is generated within Passenger - the problem is that your application code is taking too long to start.
Passenger has a default timeout of 90 seconds, see this article for more information about this problem:
It could also be that your server is so busy doing something (either CPU-wise or disk-wise) that it fails to start an application process within a reasonable amount of time. The default startup limit is 90 seconds.
Solution for this problem: Change the timeout with one of the following configuration options:
These configuration options have been introduced in version 4.0.15.
To test your application start time, you can go on your server and try the following:
time bundle exec rails c
This allows you to check how long your application is taking to load. There are a couple of things you can do to resolve this:
- Optimize your application start time - ie. make initializer code asynchronous, or load on first request etc.
- Upgrade your version of Ruby - eg. Ruby v1.9.3 is a lot slower than Ruby v2.1.3 - and does not have a lot of the optimizations. As an example, when we upgraded our stack to Ruby v2.1.3, our stack start time went from 1 minute to 10 seconds
- Add the passenger_start_timeout variable to your Nginx CustomConfig - and increase the wait time to more than 90 seconds
- Throw more horsepower at it and increase your server CPU/MEM size
For option 2, I recommend building a new development stack first and ensuring your application works with Ruby 2.1.3. Then you can either upgrade your existing stacks in-place, or create new production ones (but please be aware the caveats
For option 3, this is not a good option to keep indefinitely as your application start times will just get longer potentially - but you may want to do this as a temporary measure.