UNPKG

747 BJavaScriptView Raw
1'use strict';
2
3const co = require('co');
4
5co(function*() {
6 var ReplSet = require('mongodb-topology-manager').ReplSet;
7
8 // Create new instance
9 var topology = new ReplSet('mongod', [{
10 // mongod process options
11 options: {
12 bind_ip: 'localhost', port: 31000, dbpath: `/data/db/31000`
13 }
14 }, {
15 // mongod process options
16 options: {
17 bind_ip: 'localhost', port: 31001, dbpath: `/data/db/31001`
18 }
19 }, {
20 // Type of node
21 arbiterOnly: true,
22 // mongod process options
23 options: {
24 bind_ip: 'localhost', port: 31002, dbpath: `/data/db/31002`
25 }
26 }], {
27 replSet: 'rs'
28 });
29
30 yield topology.start();
31
32 console.log('done');
33}).catch(error => {
34 console.error(error);
35 process.exit(-1);
36});