15

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.

Elrot
  • 253
  • 1
  • 3
  • 8
  • It seems wrong. There is a suggestion: did you try creating a bundle instead of running Meteor in development mode? – imslavko Aug 31 '13 at 08:00
  • 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](https://github.com/oortcloud/node-ddp-client). Now I want to move the power of package system to the board – Elrot Aug 31 '13 at 08:38
  • According to your suggestion. Is it possible to create bundle for ARM core without having development mode up and running ?? – Elrot Aug 31 '13 at 09:09
  • Meteor is now up to version 0.7.0.1. Is it any easier to run without mongo db? – Spina Feb 04 '14 at 17:40
  • 2
    @Spina: yes. Check [my answer](http://stackoverflow.com/a/27181177/1269037). You can simply point MONGO_URL to an invalid URL. – Dan Dascalescu Nov 28 '14 at 02:48

6 Answers6

21

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

Tarang
  • 75,157
  • 39
  • 215
  • 276
  • Thanks for complete answer. – Elrot Aug 31 '13 at 09:52
  • I hope it helps!! If you get some time please blog about your experience building for the pi as it is quite difficult to do from scratch =) – Tarang Aug 31 '13 at 09:55
  • At the moment i'm using another "self build" arm board but can definitely share the knowledge :) – Elrot Aug 31 '13 at 10:01
  • This does not work with meteor 1.0.5 . The error says "ReferenceError: Meteor is not defined". – Fabrizio Fortino Mar 30 '15 at 20:46
  • @FabrizioFortino updated it for 1.0.5. Just keep in mind you can use any commit simply take the package list from the link referenced in package.js and take out any package you don't need. – Tarang Mar 30 '15 at 20:51
  • @Akshat I don't have that error anymore but the mongo server starts with my application. Same problem with meteor 1.1 – Fabrizio Fortino Apr 01 '15 at 21:46
  • @FabrizioFortino mongo is part of the meteor build toolkit. Its not possible to separate it in development mode (I think?). In production/deployment mode however it will not be required. – Tarang Apr 01 '15 at 22:17
  • For meteor 1.6 there is another list of packages https://github.com/meteor/meteor/tree/devel/packages/meteor-base – Ruben S Nov 14 '17 at 12:08
9

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.

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
7

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.

Joshua Conner
  • 882
  • 8
  • 21
  • Very interesting! I've added TingoDb support to the [Meteor roadmap](https://trello.com/c/6ugalZMG/54-additional-database-support) – Dan Dascalescu Feb 22 '14 at 22:04
5

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)

sday
  • 1,041
  • 14
  • 22
2

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.

Jim Mack
  • 1,437
  • 11
  • 16
  • Several [Mongo mocks](http://stackoverflow.com/questions/15915031/use-mock-mongodb-server-for-unit-test) exist, but you don't need any. See [my answer](http://stackoverflow.com/a/27181177/1269037). – Dan Dascalescu Nov 28 '14 at 02:50
0

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

codsimba
  • 67
  • 6