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

Did not ask to start mongod #272

Closed
subhog opened this issue Mar 31, 2014 · 10 comments
Closed

Did not ask to start mongod #272

subhog opened this issue Mar 31, 2014 · 10 comments

Comments

@subhog
Copy link

subhog commented Mar 31, 2014

Nowhere during generating my application I was instructed to start mongod myself, I only found out it's necessary after node keystone failed to connect to the db. It would be more user friendly to either:

  • Instruct new user to run mongod before starting node keystone,
  • Run mongod as a part of node keystone by default.
@s2zaman
Copy link

s2zaman commented Apr 1, 2014

Yes, that would be nice to work with KeystoneJS.

@kirkov
Copy link

kirkov commented Apr 1, 2014

Run mongod as a part of node keystone by default.

I don't have MongoDB installed on my machine. I'm connecting to a remote instance, so I don't think that would make sense.

Did you read the "Getting Started" page on keystonejs.com ?
I think it covers it pretty good:

Under "Prerequisites":

Before you begin, make sure you have Node.js and MongoDB installed.

Also, under "Problems ?":

What do you mean it couldn't find my Database?

By default, KeystoneJS will look for a MongoDB server running on localhost on > the default port, and connect to it. If you're getting errors related to the > MongoDB connection, make sure your MongoDB server is running.

If you haven't installed MongoDB yet, follow the instructions below.

To connect to a server other than localhost, add a MONGO_URI setting to the >.env file in your Keystone project directory:

@subhog
Copy link
Author

subhog commented Apr 2, 2014

I know that it's covered in the documentation, and also it's pretty easy to understand what's going on from the error displayed. However, I also believe that a part of good user experience for developers is to catch such errors and display a friendly message. There's no need someone should look for solution in documentation when it can be displayed in place. More importantly, the yo generator finish with information that you should run "node keystone" to start the application, which is false – the generated application is configured to expect mongo running locally, which is not mentioned. Following the on-screen instructions leads to an error – this should never be the case.

Running mongod as a part of Keystone does make sense. Keystone can easily check whether it's configured to connect to a local or remote db, then in case of local check whether the database is running, and then run it as a subprocess.

As a proof of concept, check out Meteor.js. That's more or less how it works there.

@JedWatson
Copy link
Member

Interesting idea.

My initial thoughts were that this isn't something Keystone should be responsible for (similar to @kirkov 's point) but @subhog makes a good point that it could be done as a fallback when looking for a database on localhost.

We should definitely update the yeoman generator to prompt for a remote connection uri, and mention running mongod if it isn't (this should be fairly easy to check for when the generator has finished running).

@kirkov
Copy link

kirkov commented Apr 2, 2014

@subhog:

Running mongod as a part of Keystone does make sense.

I'm just afraid that running mongod could be annoying to some people. Like, I use nodemon to watch for file changes, so if running mongod is part of keystone, wouldn't that restart mongod as well ?

@JedWatson
Agree. And perhaps just try to connect with the provided connection uri, as the last step of the generator, to verify the connection uri.

@subhog
Copy link
Author

subhog commented Apr 2, 2014

@kirkov: I agree, that's why I also proposed here to integrate file watcher. Plus this can be all optional.

@stennie
Copy link
Contributor

stennie commented Apr 2, 2014

I don't think it makes sense to run or install mongod as part of Keystone start up .. there are platform-specific issues (such as how to start mongod and where to look for a configuration file) and this should remain an external dependency.

Looks like keystonejs/generator-keystone#12 would add a reasonable sanity check that there is a MongoDB connection available.

@mgan59
Copy link
Contributor

mgan59 commented Apr 9, 2014

For myself I never use the default localhost:27017 for any mongo project. So by default this was busted for me.

Maybe add messaging somewhere that the configuration for a custom mongoUri is located in the .env file. As a newbie to keystone I wasn't familiar with the dotenv system and didn't know that was where to go to update my custom setting.

@mxstbr
Copy link
Collaborator

mxstbr commented Apr 29, 2016

This is a documentation issue, so I've moved this to keystonejs/keystonejs-site#86!

@mxstbr mxstbr closed this as completed Apr 29, 2016
@curtisaallen
Copy link

Hey subhog, Thanks for posting this.

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

No branches or pull requests

8 participants