Passenger: internal server error
Asked Answered
B

4

16

I installed Apache, Passenger and Sinatra and deployed an app. It gives error when trying to access:

An error occurred while starting up the preloader: it did not write a startup response in time.

Application root
    /var/www/html/test
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
    production
Ruby interpreter command

    /usr/local/bin/ruby

User and groups

    Unknown

Environment variables

    Unknown

Ulimits

    Unknown

How can I solve it?


Edit

In the application log, I found this line of error:

!> Ready
!> socket: unix:/tmp/passenger.1.0.14019/generation-0/backends/preloader.14049
!>

Gem list:

bigdecimal (1.2.0)
builder (3.2.0)
bundler (1.3.1)
daemon_controller (1.1.1)
fastthread (1.0.7)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
passenger (4.0.0.rc4)
psych (2.0.0)
rack (1.5.2)
rack-protection (1.4.0)
rake (0.9.6)
rdoc (4.0.0)
sequel (3.45.0)
sinatra (1.3.5)
test-unit (2.0.0.0)
tilt (1.3.4)

System version:

Ruby 2.0
Apache 2.2
Amazon EC2 Instance

The app was running fine with Ruby 1.9 and Passenger 3.0. I just upgraded to 2.0, and Passenger 3.0 does not even compile correctly. They suggested me to use Passenger Pre 4.0, and it compiled fine, but does not run the app...

Braca answered 10/3, 2013 at 22:15 Comment(8)
Does the Sinatra app run ok without Apache and Passenger? Which versions of Apache, Passenger, Sinatra, Ruby are you running these on, and which OS and version?Koller
Additionally, which spawn method are you using?Kaule
@Kaule Sorry I am noobie. What is spawn method?Braca
@texasbruce that a configuration option on the Apache side, but it might be irrelevant actually. Could you post more of the applications logs? The lines above and below the one you already pasted here.Kaule
@Kaule The above lines are the same as that one except with different preload.numberBraca
I dont think those are errors. If you look here: https://github.com/FooBarWidget/passenger/blob/master/helper-scripts/rack-preloader.rb at the end of negotiate_spawn_command that just debugging information, or so it seems.Kaule
I have the same problem after updating to ruby 2 and passenger 4.0rc4. my rails project starts fine, but my sinatra project has exactly the same problem. seems to be something in combination with sinatra.Licko
@markus That is so weird.. ain't they both using Rack?Braca
L
19

I found the answer what is causing it in my case. In my config.ru I was redirecting STDOUT like this:

log = File.new("logs/std.log", "a+")
STDOUT.reopen(log)

Removing the redirect into the log and it starts up again.

Looks like passenger needs STDOUT to detect a working "preloader".


Edit: I'm currently using the following solution to redirect the log into a file and keep passenger happy (basically just duplicating stdout into the log file and not redirecting):

log = File.new("logs/std.log", "a+")
def STDOUT.write string
    log.write string
    super
end
STDOUT.sync = true
Licko answered 11/3, 2013 at 23:5 Comment(5)
I removed it and it works too! But how we are supposed to log though? Is it a bug? Any bug report?Braca
Oh I found out. Only redirect stderr to the log file does the trick. They added a new "feature" that forces the stdout redirects to stderr so that is why they require unmodified stdout to start...Braca
Does anyone know if there is there a fix to this yet? I want to log accesses (including the timings) to my standard log.Attorney
This problem is documented at github.com/phusion/passenger/wiki/…. See section "Stdout redirection".Incurvate
Check your .bashrc and .profile files too for anything that prints to the screen or skips the rest of your environment if it's not running in an interactive session. Pretty idiotic if you ask me, but I spent days trying to figure that out.Petula
E
4

In case the above doesn't solve it for you, I had the exact same error message with a different cause.

In my case, we were using an external database server and that had gone down.

Bringing the external db server back up fixed the issue.

But before we solved this, we spent a bunch of time thinking about recompiling passenger, etc.

Hope this note saves someone some time.

Eckardt answered 1/4, 2013 at 15:35 Comment(0)
F
1

To solve this issue, please follow this guide by phusion phassenger https://github.com/phusion/passenger/wiki/Debugging-application-startup-problems

Felicefelicia answered 25/7, 2013 at 14:48 Comment(0)
B
1

For future reference : I had wrong database credentials in my config, which resulted in the same error.

Buckhound answered 14/1, 2015 at 6:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.