-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BadgeKit times out during startup #1460
Comments
Passenger works by waiting for an 'http.Server.listen' call. At that point, the app is considered initialized. The error message "it did not write a startup response in time" means that an 'http.Server.listen' call was not encountered in the configured timeout (60 seconds by default). Do you have any idea what may cause the app not to call |
@pbunyasrie, any updates on this? |
The application is on express 3.4.8 Correct me if I'm wrong, but I believe express uses the http.Listen call: The application runs fine when running |
Application.listen calls http.Server.listen under the hood, so it should still work:
You are using badgekit unmodified, right? I'll investigate this and see whether I can reproduce the problem. |
Yes. The only files modified were HTML template files, but those should have nothing to do with the main application itself. |
I have reproduced this problem. The investigation continues. |
Ah yes, I see the problem. It's quite trivial. The offending code block is in app/index.js: if (!module.parent) {
const port = config('PORT', 3000);
app.listen(port, function(err) {
if (err) {
throw err;
}
console.log('Listening on port ' + port + '.');
});
} ... As you can see, the This is the exact same issue as the one CompoundJS suffered from, as documented here: https://groups.google.com/forum/#!topic/phusion-passenger/6Cojr55tzfw This issue cannot be fixed without help from the application. Back in version 4.0.34 we introduced a better mechanism for this: https://github.com/phusion/passenger/blob/master/CHANGELOG#L587-L599 I'll send a pull request to Badgekit. |
BadgeKit calls `app.listen()` based on whether `module.parent` is null. But when BadgeKit is loaded from Passenger, `module.parent` is not null because Passenger does not run `index.js` directly, but `require()`s it from another file. So in this commit we also check for `module.parent.isApplicationLoader` in the conditional. Passenger sets this flag, and it is proposed that other apps (e.g. PM2) could set this flag in the future too. The `module.parent.isApplicationLoader` mechanism is used by for example the CompoundJS framework, which suffered from a similar problem. The discussion is here: https://groups.google.com/forum/#!topic/phusion-passenger/6Cojr55tzfw The mechanism is documented in the Passenger 4.0.34 changelog entry: https://github.com/phusion/passenger/blob/release-5.0.6/CHANGELOG#L577-L590 This issue was originally reported here: phusion/passenger#1460 mozilla#477
I'm trying to run a nodejs app called badgekit under phusion passenger 5.0.5 (and nodejs v0.10.33), but get this error:
I have the badgekit-api running in a separete process (independent of phusion passenger).
Badgekit-web works fine if I use forever/node instead of passenger.
I've confirmed that node.js is working under phusion passenger by creating a quick Express app.
Any advice on how to debug this further? I have a feeling that something in the application is causing problems in passenger.
The text was updated successfully, but these errors were encountered: