Meteor without mongo - mongodb

With 0.6.5 release it is possible to develop non web apps with meteor.
I rebuild it from scratch for ARM processor but I don't want DB support at all. (Mongo is a processor killer, has to high footprint and I simply don't need it)
ARM should work as DDP client only, with this in mind I build it manually without mongo.
And tried to build simplest app possible
only 1 package at start (all standard packages removed)
meteor
and one file in server folder
main = function(argv){
return "DAEMON"
}
Meteor.setInterval(function(){
console.log("HellOnWorld");
},1000);
On machine with full meteor install it works as expected
but without mongo installed I got errors
Unexpected mongo exit code 127. Restarting.
Unexpected mongo exit code 127. Restarting.
Initializing mongo database... this may take a moment.
Unexpected mongo exit code 127. Restarting.
Can't start mongod
Obviously I don't have and want mongo.
Is there any way to start meteor without waiting for mongo db ?
Meteor team plans to support other db's so it must be implemented sooner or later.

UPDATE
For newer versions of Meteor you need to remove the mongo package. The mongo package is embedded in the meteor-platform package. So you need to remove that and add all the rest back (from https://github.com/meteor/meteor/tree/devel/packages/meteor-platform):
meteor remove meteor-platform
meteor add meteor webapp logging tracker session ddp blaze spacebars templating check underscore jquery random ejson templating check underscore jquery random ejson
Then your app won't use Mongo anymore :).
In dev mode you can get rid of mongo by setting the MONGO_URL environment variable to something else and start meteor. For example: MONGO_URL=mongodb://nowhere meteor

Turns out that if you just set any MONGO_URL environment variable before running meteor, it won't start its local MongoDB! Fantastic for testing packages that don't depend on Mongo.
Before:
$ meteor test-packages ./
Testing fortawesome:fontawesome-compat...
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
After
$ MONGO_URL=mongodb://mysql.com meteor test-packages ./ # haha
Testing fortawesome:fontawesome-compat...
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started your app.
=> App running at: http://localhost:3000/
Look ma, no Mongo!
I have confirmed that no mongo process is started, and no .meteor/local/db folder is created.

In Meteor 0.6.5, you can embed TingoDb, a Node.js implementation of the MongoDB API, with your Meteor bundle instead:
1) Go to the programs/server directory in your bundle and do npm install tingodb to add TingoDb to your bundle.
2) Near the top of programs/server/packages/mongo-livedata.js, with all of the other Npm.require statements, add the following line
var Db = Npm.require('tingodb')().Db;
3) In that same file (programs/server/packages/mongo-livedata.js) replace the following code block
MongoDB.connect(url, options, function(err, db) {
if (err)
throw err;
self.db = db;
Fiber(function () {
// drain queue of pending callbacks
_.each(self._connectCallbacks, function (c) {
c(db);
});
}).run();
});
with this code:
var db = new Db('path/to/your/db/directory', {});
self.db = db;
Fiber(function () {
_.each(self._connectCallbacks, function (c) {
c(db);
});
}).run();
The path/to/your/db/directory can be anywhere, but is relative to the programs/server directory in your bundle by default.
4) To run your Meteor bundle, it wants you to export an environment variable called MONGO_URL. You could dive in to the code and remove the checks for this, but since it's never used you can just as easily export a fake MONGO_URL, like the one in your bundle's README file:
export MONGO_URL='mongodb://user:password#host:port/databasename'
5) From your bundle's base directory run node main.js.
Caveat emptor: obviously you're messing around with Meteor internals here, and this will almost assuredly break with future versions.

Meteor 1.2.1 - Just set
MONGO_URL=none
for an environment variable. (none isn't a keyword, anything invalid appears to prevent mongo from starting)

As a weird possibility, make a mock mongo server on the right port, and set your environnmental variable to access it. I'd bet you only need a few handshake routines be implemented and no more traffic after that. Beyond my capability, but it does have the advantage of not needing to adopt to code changes as things shift.

The listed answers are not working with the Meteor 1.x.
Following is my way to run meteor without mongodb and doesn't need modify anything(neither source code nor packages configuration) in meteor.
git clone https://github.com/solderzzc/mongodb-fs
cd mongodb-fs && npm install && node samples/test-server.js
you will see following console log if everything goes well
meteor create --example leaderboard && cd leaderboard
MONGO_URL=mongodb://localhost:27027/fakedb meteor
Add point to the player, and check with the mongo command line:
mongo localhost:27027/fakedb

Related

MeteorJS: use mongo shell without building meteor app [duplicate]

I would like to find out how to connect to an external MongoDB instance in Meteor.
I have added this environment
Meteor.startup(function () {
process.env.MONGO_URL = 'mongodb://[UN]:PW]#[host]:[port]/meteorTest'
});
but still the data is coming from the local database.
I want to move all the collections from my local db to this external db. I read all the tutorials, its all telling me to setup this evn variable but nothing really working. How do I test whether its connected or not?
In my own experience; I have needed to set the environment variable before starting the meteorjs server app. To do this you will need to pass the environment variable on the command-line as you invoke meteor or preset the environment for the profile that is running the meteor app on your system.
So you would start your app with this kind of a command:
MONGO_URL='mongodb://user:password#remote.domain.com:12345/' meteor
You should also make sure that the mongodb is reachable and that your user credentials are correct! I am assuming you are trying to run meteor on your local machine using a remote mongodb instance.
On Windows
You will have to create a batch file in your meteor application folder to invoke the environment variable. There is an example of this here: https://stackoverflow.com/a/29833177/1997579
I don't like to use big repeating command and I was searching for a solution where I will be setting a variable embedded with something so every time I start my meteor app; the MONGO_URL will set to environment automatically. So this what I did:
In the package.json file I replaced the start parameter as below:
"scripts": {
"start": "MONGO_URL=mongodb://username:password#host_url:portnumber/dbname meteor run"
},
Now every time I want to run my app; I run npm start instead of meteor or meteor run
Note: there is a disadvantage with that. Your db credentials will be exposed if you put your db credentials to package.json file and add this file to version control.
run it in command prompt:
"MONGO_URL=mongodb://<USER>:<PASSWORD>#<SERVER>:<PORT>/<DB> meteor"
or
save this url in run.sh file in project folder and run meteor
On windows, I set MONGO_URL in my system's environment variable and it worked fine for me.
I have created a new environment variable and it's value as MONGO_URL=mongodb://username:password#host_url:portnumber/dbname
And in path variable, I have added %MONGO_URL%
Then in meteor app root folder, I have run $meteor

Mongo 3.4 in Meteor

Is that possible to use Meteor with Mongo 3.4 for now? And if so, how to manage that?
I've tried to change packages file, but realised that version of mongo package is not a real Mongo's version.
This is indeed possible by taking care of mongodb yourself instead of letting meteor handle it. To do so you will have to fire up a mongod instance and set the MONGO_URL variable when you run meteor in development mode. In production mode you will be running a standalone mongodb instance anyway, so you will not need to change anything there.
As a reference, see this discussion on the meteor forums: https://forums.meteor.com/t/running-mongodb-3-4-locally-with-meteor/34242
To set an environment variable when running meteor in development mode requires the following:
MONGO_URL=mongodb://localhost:27017/meteor meteor
In this case you are accessing the meteor database (/meteor) on the local mongodb instance (localhost) on the standard port (:27017).

How to connect to external MongoDB instance in Meteor?

I would like to find out how to connect to an external MongoDB instance in Meteor.
I have added this environment
Meteor.startup(function () {
process.env.MONGO_URL = 'mongodb://[UN]:PW]#[host]:[port]/meteorTest'
});
but still the data is coming from the local database.
I want to move all the collections from my local db to this external db. I read all the tutorials, its all telling me to setup this evn variable but nothing really working. How do I test whether its connected or not?
In my own experience; I have needed to set the environment variable before starting the meteorjs server app. To do this you will need to pass the environment variable on the command-line as you invoke meteor or preset the environment for the profile that is running the meteor app on your system.
So you would start your app with this kind of a command:
MONGO_URL='mongodb://user:password#remote.domain.com:12345/' meteor
You should also make sure that the mongodb is reachable and that your user credentials are correct! I am assuming you are trying to run meteor on your local machine using a remote mongodb instance.
On Windows
You will have to create a batch file in your meteor application folder to invoke the environment variable. There is an example of this here: https://stackoverflow.com/a/29833177/1997579
I don't like to use big repeating command and I was searching for a solution where I will be setting a variable embedded with something so every time I start my meteor app; the MONGO_URL will set to environment automatically. So this what I did:
In the package.json file I replaced the start parameter as below:
"scripts": {
"start": "MONGO_URL=mongodb://username:password#host_url:portnumber/dbname meteor run"
},
Now every time I want to run my app; I run npm start instead of meteor or meteor run
Note: there is a disadvantage with that. Your db credentials will be exposed if you put your db credentials to package.json file and add this file to version control.
run it in command prompt:
"MONGO_URL=mongodb://<USER>:<PASSWORD>#<SERVER>:<PORT>/<DB> meteor"
or
save this url in run.sh file in project folder and run meteor
On windows, I set MONGO_URL in my system's environment variable and it worked fine for me.
I have created a new environment variable and it's value as MONGO_URL=mongodb://username:password#host_url:portnumber/dbname
And in path variable, I have added %MONGO_URL%
Then in meteor app root folder, I have run $meteor

Where to set mongodb start parameter in a meteor application on nitrous.io?

I'm studying meteor and trying some examples on nitrous.io, but the available disk space was soon consumed by the big mongo data files (including the prealloc journal files).
Unfortunately MongoDB is also new to me. I googled around and found that I can start mongoDB with some parameters like --nojournal, but I have no idea where in the nitrous.io app I can pass this parameter to mongodb at startup?
I also can't find any mongodb.conf (even *db.conf) to use the storage.smallFiles setting.
Any help would be appreciated!
Instead of using Meteor's builtin MongoDB instance, you can specify a custom instance (which you can configure the way you want).
To do this Nitrous.IO, you can follow these steps:
Create a box with Meteor template.
Install MongoDB, by running parts install mongodb (Autoparts is Nitrous.IO specific package manager)
Open the MongoDB config located at /home/action/.parts/etc/mongodb.conf
Tweak it to your liking.
Start MongoDB instance by running parts start mongodb
Now you can create a new meteor project - meteor create projectname
Finally, when you're starting meteor on your project specify the MONGO_URL environment variable. eg: MONGO_URL=mongodb://0.0.0.0:27017 meteor.
Hope this would be good enough to get started. You can also upgrade your Nitrous.IO account to increase the storage of your box.
UPDATE: I just noticed that Meteor runs its MongoDB instance with --smallfiles flag set.

When using a separate MongoDB with meteor, meteor reset stopped working

I have my MONGO_URL set to mongodb://localhost:27017/meteor and have the MongoDB run as a service.
When running my project it seems OK to store data to the separate MongoDB until I tried to run meteor reset.
My assumption is it tried to remove its default database. The error complained that myproject.meteor\local is not empty and pointed to fs.js:456 which goes to files.js:256 (rm_recursive) and so on.
any idea what and how I can fix this?
$ meteor reset only resets the bundled MongoDB. It won't reset an external Mongo database.
(That's something we should explain better in the documentation.)
In your case, try connecting to the Mongo database directly (with the mongo command line shell) and running > db.dropDatabase()