Skip to content
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

Show error message on init when NodeBB is unable to connect to the database #2322

Closed
Schamper opened this issue Oct 30, 2014 · 12 comments
Closed

Comments

@Schamper
Copy link
Contributor

It shows when doing --upgrade, but doesn't seem to show when just running the app.js.

I am using mongo, if that matters.

@barisusakli
Copy link
Member

Weird I thought we already log error messages if db connection fails
https://github.com/NodeBB/NodeBB/blob/master/src/database/mongo.js#L53
https://github.com/NodeBB/NodeBB/blob/master/src/database/mongo.js#L70

You are on mongo right?

@Schamper
Copy link
Contributor Author

Yeah I am.

This is my log when I try to launch without mongo running:

2014-10-30T20:21:58.959Z - info: NodeBB v0.5.3 Copyright (C) 2013-2014 NodeBB Inc.
2014-10-30T20:21:58.961Z - info: This program comes with ABSOLUTELY NO WARRANTY.
2014-10-30T20:21:58.961Z - info: This is free software, and you are welcome to redistribute it under certain conditions.
2014-10-30T20:21:58.961Z - info: 
2014-10-30T20:21:58.969Z - info: Time: Thu Oct 30 2014 21:21:58 GMT+0100 (West-Europa (standaardtijd))
2014-10-30T20:21:58.969Z - info: Initializing NodeBB v0.5.3
2014-10-30T20:21:58.969Z - info: * using configuration stored in: F:\Development\Node\NodeBB\config.json

Process finished with exit code 0

@barisusakli
Copy link
Member

Are you starting with ./nodebb start or node app etc? I'll give this a shot now.

@barisusakli
Copy link
Member

baris@dev:~/node-forum$ node app.js
2014-10-30T20:26:44.873Z - info: NodeBB v0.5.3-dev Copyright (C) 2013-2014 NodeBB Inc.
2014-10-30T20:26:44.878Z - info: This program comes with ABSOLUTELY NO WARRANTY.
2014-10-30T20:26:44.878Z - info: This is free software, and you are welcome to redistribute it under certain conditions.
2014-10-30T20:26:44.879Z - info:
2014-10-30T20:26:44.887Z - info: Time: Thu Oct 30 2014 20:26:44 GMT+0000 (UTC)
2014-10-30T20:26:44.887Z - info: Initializing NodeBB v0.5.3-dev
2014-10-30T20:26:44.888Z - info: * using configuration stored in: /home/baris/node-forum/config.json
2014-10-30T20:26:45.143Z - error: NodeBB could not connect to your Mongo database. Mongo returned the following error: failed to connect to [127.0.0.1:27017]

Is what I get on latest when mongo isn't running.

@barisusakli
Copy link
Member

Oh you are on windows? 😨

@Schamper
Copy link
Contributor Author

Yes haha, I start with node app btw. Mostly because of the Windows thing ;)

I do get the error message when I run node app --upgrade though.

@barisusakli
Copy link
Member

Yeah thats weird since both node app and node app --upgrade call db.init.

@barisusakli
Copy link
Member

Can you update to latest and comment out https://github.com/NodeBB/NodeBB/blob/master/app.js#L123 and see if you get a log on windows? If not im out of ideas :)

@Schamper
Copy link
Contributor Author

So I also just discovered the weirdest thing... Just arrived at work and decided to try it out on my laptop, and it does show the error. Both on 0.5.x branch.

I'll try your idea when I get home to see if that fixes it for my PC.

@Schamper
Copy link
Contributor Author

Schamper commented Nov 2, 2014

Yeah the error message displays fine with that commented out, but now it also displayed fine without it commented out...

I'm guessing it's a timing issue, where the process is already exited before winston logged the error?

@barisusakli
Copy link
Member

I'm not sure what's going on, winston just does a process.stderr.write(output + '\n'); when you log an error so it should get output. Testing a simple script on windows works fine.

process.stderr.write('sometest\n');
process.exit();

node -v 0.10.26

@barisusakli
Copy link
Member

winstonjs/winston#228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants