Skip to content

Commit

Permalink
Add dataPath option to mongo config
Browse files Browse the repository at this point in the history
  • Loading branch information
zodern committed Oct 11, 2024
1 parent d2e7c99 commit 1ff78b0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 18 deletions.
6 changes: 6 additions & 0 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ module.exports = {
// (optional, default is 3.4.1) Version of MongoDB
version: '3.4.1',

// (optional, default is the name of the app)
dbName: 'maps',

// (optional, default is /var/lib/mongodb) Folder to store the mongodb data
dataPath: '/var/lib/mongodb',

servers: {
one: {}
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions src/plugins/mongo/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ describe('module - mongo', function() {
1
);
});

it('should start Mongo 6', async () => {
const serverInfo = servers.mymongo;
sh.cd(path.resolve(os.tmpdir(), 'tests/project-mongo-6'));
sh.exec('mup docker setup && mup mongo setup');
const out = sh.exec('mup mongo start');
expect(out.code).to.be.equal(0);

expect(countOccurrences('Start Mongo: SUCCESS', out.stdout)).to.be.equal(
1
);
expect(
(await runSSHCommand(serverInfo, 'nc -z -v -w5 localhost 27017')).code
).to.be.equal(0);
});
});

describe('stop', () => {
Expand All @@ -94,21 +109,5 @@ describe('module - mongo', function() {
(await runSSHCommand(serverInfo, 'nc -z -v -w5 localhost 27017')).code
).to.be.equal(1);
});

it('should start Mongo 6', async () => {
const serverInfo = servers.mymongo;
sh.cd(path.resolve(os.tmpdir(), 'tests/project-mongo-6'));
sh.exec('mup docker setup && mup mongo setup');

const out = sh.exec('mup mongo start');
expect(out.code).to.be.equal(0);

expect(countOccurrences('Start Mongo: SUCCESS', out.stdout)).to.be.equal(
1
);
expect(
(await runSSHCommand(serverInfo, 'nc -z -v -w5 localhost 27017')).code
).to.be.equal(0);
});
});
});
2 changes: 1 addition & 1 deletion src/plugins/mongo/command-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function setup(api) {
vars: {
mongoVersion: mongoConfig.version,
mongoshCmd: mongoConfig.version.split('.')[0] > 5 ? 'mongosh' : 'mongo',
mongoDbDir: '/var/lib/mongodb'
mongoDbDir: mongoConfig.dataPath || '/var/lib/mongodb'
}
});

Expand Down
1 change: 1 addition & 0 deletions src/plugins/mongo/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const schema = joi.object().keys({
oplog: joi.bool(),
port: joi.number(),
dbName: joi.string(),
dataPath: joi.string(),
version: joi.string(),
servers: joi.object().keys().required()
});
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/project-mongo-6/mup.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
},
mongo: {
version: '6.0.18',
dataPath: '/opt/mongo-5-data',
servers: {
mymongo: {}
}
Expand Down

0 comments on commit 1ff78b0

Please sign in to comment.