Skip to content

Commit

Permalink
Add mongo-dev-server package (#8853)
Browse files Browse the repository at this point in the history
* Add mongo-dev-server package

Only start the MongoDB server if this package
is present in the project.

* Small layout/formatting adjustments; updated README.

* Allow tests using fake-mongod to start (fake) Mongo.

* Adjust test stdout matching to be less sensitive to ordering.

* Add `mongo-dev-server` History.md entry.

* Remove mongo start check since the tested for error prevents mongo startup.

* Remove README traling whitespace.

* Bump mongo package version.
  • Loading branch information
zimme authored and abernix committed Jul 26, 2017
1 parent 0180985 commit a1c2eef
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 5 deletions.
12 changes: 12 additions & 0 deletions History.md
Expand Up @@ -20,6 +20,18 @@
* The `meteor-promise` package has been upgraded to version 0.8.5,
and the `promise` polyfill package has been upgraded to 8.0.1.

* A new package called `mongo-dev-server` has been created and wired into
`mongo` as a dependency. As long as this package is included in a Meteor
application (which it is by default since all new Meteor apps have `mongo`
as a dependency), a local development MongoDB server is started alongside
the application. This package was created to provide a way to disable the
local development Mongo server, when `mongo` isn't needed (e.g. when using
Meteor as a build system only). If an application has no dependency on
`mongo`, the `mongo-dev-server` package is not added, which means no local
development Mongo server is started.
[Feature Request #31](https://github.com/meteor/meteor-feature-requests/issues/31)
[PR #8853](https://github.com/meteor/meteor/pull/8853)

* `Accounts.config` no longer mistakenly allows tokens to expire when
the `loginExpirationInDays` option is set to `null`.
[Issue #5121](https://github.com/meteor/meteor/issues/5121)
Expand Down
18 changes: 18 additions & 0 deletions packages/mongo-dev-server/README.md
@@ -0,0 +1,18 @@
# mongo-dev-server

[Source code of released version](https://github.com/meteor/meteor/tree/master/packages/mongo-dev-server) | [Source code of development version](https://github.com/meteor/meteor/tree/devel/packages/mongo-dev-server)
***

When the `mongo-dev-server` package is included in a Meteor application, a
local development MongoDB server is started alongside the application. This
package is mostly used internally, as it is included by default with any
application that has a dependency on `mongo` (which is most Meteor
applications). In some cases however, people might be interested in
using the Meteor Tool without having to start a local development Mongo
instance (e.g. when using Meteor as a build system). If an application has no
dependency on `mongo`, the `mongo-dev-server` package will be removed
(since it is a direct dependency of the `mongo` package), and no local
development Mongo server will be started.

Note this is a `debugOnly` package, meaning it will not be included in any
production bundles.
12 changes: 12 additions & 0 deletions packages/mongo-dev-server/package.js
@@ -0,0 +1,12 @@
Package.describe({
debugOnly: true,
documentation: 'README.md',
name: 'mongo-dev-server',
summary: 'Start MongoDB alongside Meteor, in development mode.',
version: '1.0.0',
});

Package.onUse(function (api) {
api.use('modules');
api.mainModule('server.js', 'server');
});
3 changes: 3 additions & 0 deletions packages/mongo-dev-server/server.js
@@ -0,0 +1,3 @@
if (process.env.MONGO_URL === 'no-mongo-server') {
Meteor._debug('Note: Restart Meteor to start the MongoDB server.');
}
3 changes: 2 additions & 1 deletion packages/mongo/package.js
Expand Up @@ -34,7 +34,8 @@ Package.onUse(function (api) {
'diff-sequence',
'mongo-id',
'check',
'ecmascript'
'ecmascript',
'mongo-dev-server',
]);

// Binary Heap data structure is used to optimize oplog observe driver
Expand Down
19 changes: 18 additions & 1 deletion tools/runners/run-all.js
Expand Up @@ -71,10 +71,20 @@ class Runner {
onFailure
});

buildmessage.capture(function () {
self.projectContext.resolveConstraints();
});

const packageMap = self.projectContext.packageMap;
const hasMongoDevServerPackage =
packageMap && packageMap.getInfo('mongo-dev-server') != null;
self.mongoRunner = null;
if (mongoUrl) {
oplogUrl = disableOplog ? null : oplogUrl;
} else {
} else if (hasMongoDevServerPackage
|| process.env.METEOR_TEST_FAKE_MONGOD_CONTROL_PORT) {
// The mongo-dev-server package is required to start Mongo, but
// tests using fake-mongod are exempted.
self.mongoRunner = new MongoRunner({
projectLocalDir: self.projectContext.projectLocalDir,
port: mongoPort,
Expand All @@ -86,6 +96,13 @@ class Runner {

mongoUrl = self.mongoRunner.mongoUrl();
oplogUrl = disableOplog ? null : self.mongoRunner.oplogUrl();
} else {
// Don't start a mongodb server.
// Set monogUrl to a specific value to prevent MongoDB connections
// and to allow a check for printing a message if `mongo-dev-server`
// is added while the app is running.
// The check and message is printed by the `mongo-dev-server` package.
mongoUrl = 'no-mongo-server';
}

self.updater = new Updater();
Expand Down
5 changes: 3 additions & 2 deletions tools/tests/compiler-plugins.js
Expand Up @@ -314,11 +314,12 @@ selftest.define("compiler plugins - inactive source", () => {
s.createApp('myapp', 'uses-published-package-with-inactive-source');
s.cd('myapp');

let run = startRun(s);
const run = s.run();
run.match('myapp');
run.matchBeforeExit('Started proxy');
run.match('Errors prevented startup');
run.match('no plugin found for foo.sourcish in glasser:use-sourcish');
run.match('none is now');

run.stop();
});

Expand Down
2 changes: 1 addition & 1 deletion tools/tests/static-html.js
Expand Up @@ -54,7 +54,7 @@ selftest.define("static-html - throws error", () => {
s.cd('myapp');

const run = startRun(s);
run.match("Attributes on <head> not supported");
run.matchBeforeExit("Attributes on <head> not supported");

run.stop();
});

0 comments on commit a1c2eef

Please sign in to comment.