MongoDB - Meteor 1.4 32-bit deprecated is an issue?; Using MONGO_URL

This issue has been inherent in a ll previous builds and it was promised that this would resolved in Meteor 1.4 ( I recall reading this somewhere).

Is there a way to force meteor to make use of 64 bit Mongo? All projects are being nagged by a warning in the console stating that I am using a deprecated version of mongo (32-bit).

I don’t want to see comments explaining why the problem’s still there. I only want some proper instructions to get meteor to use a 64 bit mongo. There seems to be no issues with the 64 bit Mongo on Windows 10 now. So I see no issue why devs are not given an upgrade path here.

I also read somewhere (I think on StackOverflow) that the 32-bit is used in dev-mode and that its a non issue in production mode as it allows you to use any version. I however could not find anything to verify this.

Please help

1 Like

This is basically true, in that Meteor dev installs a local MongoDB for you. In production you have to install your own MongoDB (or connect to a third party service).

However, you can also install-or-connect in dev. So, on Windows install your own local MongoDB or connect to a 3rd party service, and set your MONGO_URL accordingly. For example (locally installed):

set MONGO_URL=mongodb://localhost:27017/database_name
meteor

Check also this post:

4 Likes

on a different note (looking at the above). Is it possible to create two separate meteor apps and one common mongodb? or would i have to go into an issue of replication in such a scenario?

No problem. Although you will need to make sure you use a different database name for each app (unless you want them to share the same collections).

2 Likes

I think i have to rephrase that (my fault). What i meant was “is it possible to have multiple apps running on the same set of collections”? I’m still fairly new to mongo so i tend to use db terminology. Sorry.

Absolutely - just use the same MONGO_URL (including the database name) and they will share the same collections.

2 Likes

Thanks so to recap where do i find the url setting for the mongodb of the given app? Is it in a config file? As i’d rather not use the command line. I will try to install a 64 bit mongo locally and point meteor to use that one.

If you install it on your local dev machine, it will be `mongodb://localhost:27017" by default.

Meteor dev defaults to a database name of meteor by default, but I suggest explicitly specifying the name as in my first reply, so something like mongodb://localhost:27017/database_name.

MongoDB has a configuration file, which you can edit if you need to change things like the port number.

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

2 Likes

That i realised it has two db’s ‘local’ and ‘meteor’ . But how do i make a meteor app Point to the separately installed MongoDB? Would meteor locate the informaiton from that mongo configuration file?

Ah - no - you need to set it as an environment variable.

1 Like

Is there a way to run two meteor applications, have them speak to one instance of mongo (share collections), all at the same time on your local box?

Yes - you just need to run each application on a different port.

2 Likes

Thanks. I’d run meteor like so: meteor --port 3030

I also have to specify the mongo URL like so: mongodb://localhost:27017/database_name? If so, where does this go?

you would do …

after running your meteor app in command prompt

you set the following environment variables in both apps as follows :

$ MONGO_URL=mongodb://x.x.x.x:xxxxx/myappdb

if you want to test more than one app in tandem on the same machine out you would specify a different port number when running it from command prompt like so …

meteor --port 8000

When you don’t specify a port number it defaults to 3000. …

Cheers

1 Like

you could do it via command prompt inside the meteor if you are on windows (assuming you’re admin))

set MONGO_URL=mongodb:pornumber/database_name

then run meteor

1 Like

Thank you @metrophobe. I’m on macOS by the way.

So where is MONGO_URL=mongodb:portnumber/databasename actually stored, locally on my dev box, and on the server? In a settings.json file for example?

On dev, I use package.json:
"scripts": { "dev": "MONGO_URL=mongodb://localhost:27017/your_db_name meteor --settings settings.json" }

and then, instead of meteor, you just: npm run dev
( the --settings settings.json is optional, to include other options )

On the server-side: it depends on how you deploy. If you use MUP, you can specify it in mup.json

1 Like

@eleventy

Right now I start meteor like so:

meteor --settings .config/development/settings.json

but my settings.json file doesn’t have a ‘scripts’ tag within it. This file is used for my private/public app settings.

Could I just add the following to my existing settings.json file and have it work locally?

 "dev": "MONGO_URL=mongodb://localhost:27017/your_db_name"

Nope. It goes into package.json, the npm package file

Hi there,

Read your post in my other thread which is totally unrelated to what you are trying to accomplish here. Just to clarify how settings (settings.json) and startup (package.json) scripts work.

settings.json is there primarily to allow you to put in config settings that are spread application-wide (if needed). Setting them as private makes them available to the server whereas setting them as public makes them available both to client and server. By default they are only available to the server. Note that these are made available AFTER the app starts running. And I am starting to think that MONGO_URL cannot be modified dynamically after startup (but that’s just me). In order to force your app to use the settings you have to run your meteor app with the following command.

meteor --settings settings.json

Now package.json is an optional file (which sits in the root of your app. It might not be there so you would have to create it). package.json is YAJF which gives you the facility to put in start-up scripts BEFORE the app runs. A sample for your scenario is shown below:

{
  "name": "yourappname",
  "scripts": {
  "start": "MONGO_URL=mongodb://localhost:27017/meteorprojectname meteor --port 5000"
}

Since meteor is built on-top of NodeJS you can then make use of npm to locate this package.json and start the related script. You could have multiple scripts but since mine is called ‘start’ you would invoke the config script start via npm inside your project folder like so…

npm start

Notwithstanding all this, what I was trying to do was to change process.env (environment variable) inside Meteor.onStartup() and this is different from what you required.

Hope this helps.

2 Likes