15
votes

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.

6
It seems wrong. There is a suggestion: did you try creating a bundle instead of running Meteor in development mode? - imslavko
Nope because I'm trying to use meteor for embedded programming and I need it in development mode to write low level board support packages (interrupts etc) I have working prototype with this DDP Client. Now I want to move the power of package system to the board - Elrot
According to your suggestion. Is it possible to create bundle for ARM core without having development mode up and running ?? - Elrot
Meteor is now up to version 0.7.0.1. Is it any easier to run without mongo db? - Spina
@Spina: yes. Check my answer. You can simply point MONGO_URL to an invalid URL. - Dan Dascalescu

6 Answers

21
votes

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

9
votes

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.

7
votes

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.

5
votes

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)

2
votes

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.

0
votes

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.

  1. git clone https://github.com/solderzzc/mongodb-fs
  2. cd mongodb-fs && npm install && node samples/test-server.js

    you will see following console log if everything goes well

    enter image description here

  3. 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

enter image description here