repl.js 747 B

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