Giter Site home page Giter Site logo

run-rs's Introduction

run-rs

Zero-config MongoDB runner. Starts a replica set with no non-Node dependencies, not even MongoDB.

Usage

To install:

npm install run-rs -g

With run-rs, starting a 3 node replica set running MongoDB 3.6 is a one-liner.

run-rs

To use a different version, use the -v flag. For example, this will start a 3 node replica set using MongoDB 4.0.0.

run-rs -v 4.0.0

On linux, for 4.2.0 version, by default download ubuntu1604, change with command

run-rs -l ubuntu1804

Clearing the Database

Run-rs clears the database every time it starts by default. To override this behavior, use the --keep (-k) flag.

run-rs --keep

OS Support

Run-rs supports Linux, OSX, and Windows 10 (via git bash or powershell).

Shell Option

Use the --shell flag to start a MongoDB shell connected to your replica set once the replica set is running.

$ run-rs --shell
Purging database...
Running '/home/node/lib/node_modules/run-rs/3.6.5/mongod'
Starting replica set...
Started replica set on "mongodb://localhost:27017,localhost:27018,localhost:27019"
Connecting shell /home/node/lib/node_modules/run-rs/3.6.5/mongo
rs:PRIMARY>

Notes on Connecting

Use replicaSet=rs in your connection string.

For Windows Users: Do NOT use localhost or 127.0.0.1 for the host name in your connection string, use computer name instead. See example connection string below:

mongodb://sk-zm-los-bdb:27017,sk-zm-los-bdb:27018,sk-zm-los-bdb:27019/dbname?replicaSet=rs

where sk-zm-los-bdb is the hostname or the name of your computer, dbname is the name of your database, and rs is the name of your replica set.

Reusing a Pre-installed MongoDB Version

By default, run-rs will download whatever version of MongoDB you've specified. If you already have MongoDB installed, you can use the --mongod option:

run-rs --mongod

The above command will just run whatever mongod is on your PATH. If you want to run a specific mongod server, you can do this:

run-rs --mongod /home/user/path/to/mongod

Specify the data directory

By default, run-rs will store data files in a directory named 'data'. To specify a dbPath for run-rs to use as a data directory, use the --dbpath option.

run-rs --dbpath /path/to/data/directory

IP Binding

Use the --host option to ensure that run-rs allows MongoDB to listen for connections on configured IP addresses or hostnames other than localhost and 127.0.0.1. See examples below:

run-rs --host 198.51.100.1

OR

run-rs --host example-associated-hostname

Note: Before you bind to other ip addresses, consider enabling access control and other security measures listed in Security Checklist to prevent unauthorized access.

Ports

By default, run-rs will start MongoDB servers on ports 27017, 27018, and 27019. You can override this default using the --portStart option. For example, the below command will start MongoDB servers on ports 27000, 27001, and 27002.

run-rs --portStart 27000

Running in Production

Do not use run-rs for running your production database. Run-rs is designed for local development and testing, and is not intended for production use. If you want to run MongoDB in production and don't want to manage a replica set yourself, use MongoDB Atlas.

run-rs's People

Contributors

chaiwa-berian avatar fiorillo avatar fonger avatar fruschitaly avatar gabrie-allaigre avatar gracicot avatar isghe avatar jordonbiondo avatar lineus avatar sanguineti avatar ucejtech avatar vkarpov15 avatar xaseron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

run-rs's Issues

What the hell.....

I hitted this command and ~/data directory cleaned...
This very rediculus thing in this command. at least you need to ask command will use your dirctory and do you want to remove it.
There are no any notification about deleting directory....

F__k....

Please fix this otherwise other people can suffer same problem.

mongoerror in windows powershell

my run-rs version is 0.2.1 , when I run run-rs -v 4.0.0 ,and get the following error:
did I miss some additional configs ?

Purging database...
Running 'C:\Users\super\AppData\Roaming\npm\node_modules\run-rs/4.0.0/mongod.exe'
Starting replica set...
MongoError: This node was not started with the replSet option
    at Function.MongoError.create (C:\Users\super\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\node_modules\mongodb-core\lib\error.js:31:11)
    at C:\Users\super\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\node_modules\mongodb-core\lib\connection\pool.js:497:72
    at authenticateStragglers (C:\Users\super\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\node_modules\mongodb-core\lib\connection\pool.js:443:16)
    at Connection.messageHandler (C:\Users\super\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\node_modules\mongodb-core\lib\connection\pool.js:477:5)
    at Socket.<anonymous> (C:\Users\super\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\node_modules\mongodb-core\lib\connection\connection.js:333:22)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:601:20)

colors dependecy attack through prettyjson

Issue:
Install run-rs in a new project would result in installing malicious package, colors > 1.4.0 (Causing infinite loop prints on your system).

Solution:
The issue has already been reported and fixed in prettyjson, a new version has not yet been published to npm.
rafeca/prettyjson#54

Once published please update prettyjson to 1.2.2 (or whatever tag will be used).

Temporary workaround:
add colors as a top level dependency npm install [email protected].

Thanks:
run-rs is awesome and a crucial part of testing in multiple projects I work on. Thank you so much @vkarpov15 for all your hard work on this!

Can't connect with --bind_ip_all flag

Hello there,

I am ussing mongodb hostname in docker container with MONGODB_URL=mongodb://mongodb:27017,mongodb:27018,mongodb:27019/test?replicaSet=rs connection string for tests, but I can't connect to it after 0.7.0 run-rs release.

I use the command to run docker image:

CMD ["run-rs", "--host", "mongodb", "--mongod"]

It works fine when I use RUN npm install [email protected] --unsafe-perm -g
How should I connect to it?

Support for Windows

When I run the package with command run-rs --version 4.0.0 occur error
ReferenceError: type is not defined at getOS (C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\dl.js:27:49) at dl (C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\dl.js:6:14) at run (C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\index.js:38:5) at run.next (<anonymous>) at onFulfilled (C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\node_modules\co\index.js:65:19) at C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\node_modules\co\index.js:54:5 at new Promise (<anonymous>) at co (C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\node_modules\co\index.js:50:10) at Object.<anonymous> (C:\Users\PC\AppData\Roaming\nvm\v8.9.4\node_modules\run-rs\index.js:23:1) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Function.Module.runMain (module.js:684:10) at startup (bootstrap_node.js:187:16)
Please help me resolve this issue
Thanks for the support!

Using --keep flag fails on first run

If I include the --keep flag on the first run I get an error and mongo won't start. I'd like to just have something like this in my package.json and be able to use the same command on the first run and any subsequent runs:

"start:mongo": "run-rs -v 4.0.1 --keep"

Unreadable error if --mongod path not found

I installed this. I also have Mongo 4.0.6 installed. When I run run-rs --mongod it fails with this message:

C:\Users\user\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\lib\replset.js:124
            .toString()
             ^

TypeError: Cannot read property 'toString' of null
    at ChildProcess.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\lib\replset.js:124:14)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Socket.stream.socket.on (internal/child_process.js:336:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:561:12)

So I commented out the proc.on('close', function() to see, but when I run, it still fails with:

$ run-rs --mongod
Purging database...
Running 'mongod' [ 27017, 27018, 27019 ]
Starting replica set...
Error: spawn mongod ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:362:16)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)
    at Function.Module.runMain (module.js:696:11)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Please is there any pointers how to make this work? I just want to try out transactions in NodeJS Mongoose.

moment.js security vulnerability

A security issue has been detected in moment library.
Details in this link

moment  <2.29.2
Severity: high
Path Traversal: 'dir/../../filename' in moment.locale - https://github.com/advisories/GHSA-8hfj-j24r-96c4

MongoDB 4.4.2 fails to start

mcwr@arch ~ % npm list -g --depth=0
/home/mcwr/.npm-packages/lib
└── [email protected]
mcwr@arch ~ % .npm-packages/bin/run-rs -v 4.4.2
Purging database...
Running '/home/mcwr/.npm-packages/lib/node_modules/run-rs/4.4.2/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
(node:3960) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3960) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:3960) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:3960) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
/home/mcwr/.npm-packages/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124
            .toString()
             ^

TypeError: Cannot read property 'toString' of null
    at ChildProcess.<anonymous> (/home/mcwr/.npm-packages/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124:14)
    at ChildProcess.emit (node:events:376:20)
    at maybeClose (node:internal/child_process:1055:16)
    at Socket.<anonymous> (node:internal/child_process:441:11)
    at Socket.emit (node:events:376:20)
    at Pipe.<anonymous> (node:net:661:12)

ECONNRESET on Windows

See below:

PS D:\> run-rs --keep --host 192.168.100.5
Skipping purge
Running 'C:\Users\x\AppData\Roaming\nvm\v12.8.0\node_modules\run-rs\4.0.12\mongod.exe' [ 27017, 27018, 27019 ]
Restarting replica set...
events.js:180
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:183:27)
Emitted 'error' event at:
    at Socket.<anonymous> (C:\Users\x\AppData\Roaming\nvm\v12.8.0\node_modules\run-rs\node_modules\mongodb-core\lib\connection\connection.js:321:10)
    at Object.onceWrapper (events.js:291:20)
    at Socket.emit (events.js:203:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  name: 'MongoNetworkError',
  errorLabels: [ 'TransientTransactionError' ],
  [Symbol(mongoErrorContextSymbol)]: {}
}

ubuntu 16.04 LTS install failed

global install

sudo npm i run-rs -g

/usr/local/bin/run-rs -> /usr/local/lib/node_modules/run-rs/index.js

> [email protected] install /usr/local/lib/node_modules/run-rs/node_modules/kerberos
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=11.6.0 runtime=node arch=x64 libc= platform=linux)
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/run-rs/node_modules/kerberos/build'
gyp ERR! System Linux 4.15.0-46-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/run-rs/node_modules/kerberos
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dtboy/.npm/_logs/2019-03-28T01_19_53_661Z-debug.log

install

npm i run-rs

[email protected] install /home/dtboy/node_modules/kerberos
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=11.6.0 runtime=node arch=x64 libc= platform=linux)
make: Entering directory '/home/dtboy/node_modules/kerberos/build'
  CXX(target) Release/obj.target/kerberos/src/kerberos.o
In file included from ../src/kerberos_common.h:7:0,
                 from ../src/kerberos.h:5,
                 from ../src/kerberos.cc:1:
../src/unix/kerberos_gss.h:18:31: fatal error: gssapi/gssapi.h: 没有那个文件或目录
compilation terminated.
kerberos.target.mk:104: recipe for target 'Release/obj.target/kerberos/src/kerberos.o' failed
make: *** [Release/obj.target/kerberos/src/kerberos.o] Error 1
make: Leaving directory '/home/dtboy/node_modules/kerberos/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Linux 4.15.0-46-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/dtboy/node_modules/kerberos
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/home/dtboy/package.json'
npm WARN dtboy No description
npm WARN dtboy No repository field.
npm WARN dtboy No README data
npm WARN dtboy No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dtboy/.npm/_logs/2019-03-28T01_20_48_156Z-debug.log

I wonder if there is a problem with my system configuration or with this library. thanks a lot

Auto run on startup

Hello. Anyone can help on how do I run this on startup?

On Ubuntu and Mac.

Thanks.

daemon support?

First, thanks to the author's library
It always runs in the foreground, can support daemon mode? ( i test it in windows and linux both are foreground)
I used the library for automated testing, and now I can only run run-rs & like this

Error: dbpath is required

When I run this command, as per the documentation:

run-rs -v 4.0.0 --shell

I receive the following error:

Error: dbpath is required

So I try to specify the path, like this:

run-rs -v 4.0.0 --shell --dbpath /my/folder

but this yields the same error. I have also tried:

run-rs -v 4.0.0 --shell --dbpath=/my/folder

How can I fix this? This is now a blocker for my project.

Thanks!

PR for support 4.2.0

Hi,

I'm create pull request #40

I'm tested on windows & macos.

On linux, with ubuntu >= 18.04

run-rs -l ubuntu1804

options `--host` and `--help`, have same shortcut `-h`

options --host and --help, have same shortcut -h

 run-rs --help

  Usage: run-rs [options]

  Options:

    -v, --version [version]  Version to use
    -k, --keep               Use this flag to skip clearing the database on startup
    -s, --shell              Use this flag to automatically open up a MongoDB shell when the replica set is started
    -q, --quiet              Use this flag to suppress any output after starting
    -m, --mongod             Skip downloading MongoDB and use this executable. If blank, just uses `mongod`. For instance, `run-rs --mongod` is equivalent to `run-rs --mongod mongod`
    -n, --number [num]       Number of mongods in the replica set. 3 by default.
    -p, --portStart [num]    Start binding mongods contiguously from this port. 27017 by default.
    -d, --dbpath [string]    Specify a path for mongod to use as a data directory. `./data` by default.
    -h, --host [string]      Override the default ip binding and bind mongodb to listen to other ip addresses. Bind to localhost or 127.0.0.1 by default
    -h, --help               output usage information

Auth flag

So my development MongoDB is exposed because it is on a Lightsail VPS and I'd like to secure it with the --auth flag.
I tried adding it myself, seemed like a small feature but I'm getting some errors in the underlying topology manager when adding the auth flag.

bind to different interface

Run-rs binds to localhost by default, but I need it to listen on a different interface. Is that possible?

Is it possible to configure the ports?

Currently I think the replica set is running on ports 27017, 27018 and 27019. Is it possible to configure these to run on different ports using some flag?

I require this for my local setup since I already have a MongoDB server running for a different project and do not want to stop it every time.

PS: I do not want to use the existing mongo since both are different projects.

Error: Server is unavailable

I am getting error while try to start run-rs. When I check data folder, folder 27017 contain some files, but 27018 and 27019 are empty. MongoDB is running at 27017, but it looks like that it wont start servers at 27018 and 27019.

OS: archlinux 5.10.83-1-lts
Node: v17.1.0.
npm: 8.1.3

Purging database... Running '/usr/lib/node_modules/run-rs/4.0.12/mongod' [ 27017, 27018, 27019 ] Starting replica set... Error: Server is unavailable at /usr/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/utils.js:79:40 at Socket.<anonymous> (/usr/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/utils.js:43:5) at Socket.emit (node:events:390:28) at emitErrorNT (node:internal/streams/destroy:164:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at processTicksAndRejections (node:internal/process/task_queues:83:21)

Merge pending PR #32

Hi, and thanks for this great module, it's being really helpful :)

I just tried using the --help option, but it does not work (version 0.5.2, latest available on npm). I was going to submit a PR to fix it, and then realized it was already fixed on #32

It would be great if you can release a new version including this fix.

--keep option, way to avoid logging entire db contents on start?

When launching run-rs with the --keep option, it seems to print the entire contents of the db to the terminal on launch. If you've been using it for awhile, this can be a lot - yet I cannot seem to find a way to prevent this logging. How can I suppress that initial terminal-log of the full db contents?

Using run-rs in other node modules

Hi @vkarpov15

I'm trying to run some automated tests that use a MongoDB replica set.

My tests currently use jest and mongodb-memory-server, which does not yet support running replica sets.

I was wondering if there was a viable way to use run-rs in another node project, maybe by importing it or executing it as a child process?

Thanks!

TypeError: Cannot read property 'toString' of null when running mongodb 4.2

Not sure if this is fixed in 0.7.0, as that version gives me another error (same as #46).

I am running version 0.6.2 in a docker container, which works fine when running mongodb 4.0 but not 4.2.

My dockerfile looks like the following:

FROM node:12-stretch

RUN apt-get install libkrb5-dev
RUN npm install [email protected] --unsafe-perm -g
CMD ["run-rs","--keep", "-q", "--version", "4.0.0", "--host", "mongo"]

And the output of my container is the following:

Downloading MongoDB 4.2.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  109M    0     0  16.0M      0  0:00:06  0:00:06 --:--:-- 17.8M
Copied MongoDB 4.2.0 to '/usr/local/lib/node_modules/run-rs/4.2.0'
Skipping purge
Running '/usr/local/lib/node_modules/run-rs/4.2.0/mongod' [ 27017, 27018, 27019 ]
Restarting replica set...
/usr/local/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/server.js:101
            .toString()
             ^

TypeError: Cannot read property 'toString' of null
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/server.js:101:14)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:674:12)

running in docker or drone CI

I'm trying to run this on drone CI inside an image containing node and python. I'm not sure why the mongodb won't start, although it is running fine in my laptop. Here is the error trace:

+ npm install run-rs -g --unsafe-perm
/usr/bin/run-rs -> /usr/lib/node_modules/run-rs/index.js

> [email protected] install /usr/lib/node_modules/run-rs/node_modules/kerberos
> prebuild-install || node-gyp rebuild

+ [email protected]
added 98 packages from 63 contributors in 6.79s
+ run-rs --version 4.0.0 --shell
Downloading MongoDB 4.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0 67.3M    0 12888    0     0  14997      0  1:18:26 --:--:--  1:18:26 14986
  0 67.3M    0  225k    0     0   122k      0  0:09:23  0:00:01  0:09:22  122k
  5 67.3M    5 3752k    0     0  1325k      0  0:00:52  0:00:02  0:00:50 1324k
 33 67.3M   33 22.6M    0     0  6057k      0  0:00:11  0:00:03  0:00:08 6056k
 63 67.3M   63 42.7M    0     0  9049k      0  0:00:07  0:00:04  0:00:03 9048k
 93 67.3M   93 62.7M    0     0  10.7M      0  0:00:06  0:00:05  0:00:01 12.6M
100 67.3M  100 67.3M    0     0  11.1M      0  0:00:06  0:00:06 --:--:-- 15.9M
Copied MongoDB 4.0.0 to '/usr/lib/node_modules/run-rs/4.0.0'
Purging database...
Running '/usr/lib/node_modules/run-rs/4.0.0/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
Error: failed to start mongod with options --port=27017,--dbpath=/drone/src/bitbucket.org/companyName/repoName/data/27017,--bind_ip=localhost,--replSet=rs
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] MongoDB starting : pid=77 port=27017 dbpath=/drone/src/bitbucket.org/companyName/repoName/data/27017 64-bit host=1166178b3527
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] db version v4.0.0
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] git version: 3b07af3d4f471ae89e8186d33bbb1d5259597d51
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] modules: none
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] build environment:
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten]     distarch: x86_64
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2019-04-10T07:44:38.108+0000 I CONTROL  [initandlisten] options: { net: { bindIp: "localhost", port: 27017 }, replication: { replSet: "rs" }, storage: { dbPath: "/drone/src/bitbucket.org/companyName/repoName/data/27017" } }
2019-04-10T07:44:38.108+0000 I STORAGE  [initandlisten] 
2019-04-10T07:44:38.109+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-04-10T07:44:38.109+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-04-10T07:44:38.109+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3481M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-04-10T07:44:38.832+0000 I STORAGE  [initandlisten] WiredTiger message [1554882278:832122][77:0x7fc08bf969c0], txn-recover: Set global recovery timestamp: 0
2019-04-10T07:44:38.842+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-04-10T07:44:38.858+0000 I CONTROL  [initandlisten] 
2019-04-10T07:44:38.858+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-04-10T07:44:38.858+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-04-10T07:44:38.858+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-04-10T07:44:38.858+0000 I CONTROL  [initandlisten] 
2019-04-10T07:44:38.859+0000 I CONTROL  [initandlisten] 
2019-04-10T07:44:38.859+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-04-10T07:44:38.859+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-04-10T07:44:38.859+0000 I CONTROL  [initandlisten] 
2019-04-10T07:44:38.861+0000 I STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 1dcd13ef-c7f6-41b7-a4fa-1f22464c83fa
2019-04-10T07:44:38.878+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/drone/src/bitbucket.org/companyName/repoName/data/27017/diagnostic.data'
2019-04-10T07:44:38.878+0000 I STORAGE  [initandlisten] createCollection: local.replset.oplogTruncateAfterPoint with generated UUID: 04bdc563-1be9-497a-bcd8-bdab113ef77e
2019-04-10T07:44:38.890+0000 I STORAGE  [initandlisten] createCollection: local.replset.minvalid with generated UUID: 600af822-b8fb-49a9-822c-71d85de883a3
2019-04-10T07:44:38.903+0000 I REPL     [initandlisten] Did not find local voted for document at startup.
2019-04-10T07:44:38.904+0000 I REPL     [initandlisten] Did not find local Rollback ID document at startup. Creating one.
2019-04-10T07:44:38.904+0000 I STORAGE  [initandlisten] createCollection: local.system.rollback.id with generated UUID: 4793499d-ac02-427a-85c4-d58fc776b886
2019-04-10T07:44:38.917+0000 I REPL     [initandlisten] Initialized the rollback ID to 1
2019-04-10T07:44:38.917+0000 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2019-04-10T07:44:38.917+0000 I CONTROL  [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Replication has not yet been configured
2019-04-10T07:44:38.917+0000 I STORAGE  [initandlisten] exception in initAndListen std::exception: listen: Address already in use, terminating
2019-04-10T07:44:38.918+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-04-10T07:44:38.918+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-04-10T07:44:38.918+0000 I REPL     [initandlisten] shutting down replication subsystems
2019-04-10T07:44:38.917+0000 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: Replication has not yet been configured
2019-04-10T07:44:38.926+0000 I FTDC     [initandlisten] Shutting down full-time diagnostic data capture
2019-04-10T07:44:38.926+0000 I STORAGE  [initandlisten] WiredTigerKVEngine shutting down
2019-04-10T07:44:39.008+0000 I STORAGE  [initandlisten] shutdown: removing fs lock...
2019-04-10T07:44:39.008+0000 I CONTROL  [initandlisten] now exiting
2019-04-10T07:44:39.008+0000 I CONTROL  [initandlisten] shutting down with code:100

    at ChildProcess.<anonymous> (/usr/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/server.js:404:15)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)



Windows Support not working

Hi,

So trying to use multi-document in MongoDB I found that I need replicat-set and then I find your npm pacakge and I was like "that's perferct :)"

I run the command to install globally and it's seem good. Then I try to run "run-rs -v 4.0.0" but the command failed with the following error :
run-rs1

My guess will be that there is an error in the command to create the folder for the database?

Or am I doing something wrong?

I have version 0.3.0

Thanks in advance

How to disable console output

Is there any way to disable console output from run-rs command? When I do a mongorestore for a dataset about 500MB on the replica set, it takes a long time for the console output to finish.

error when running run-rs when another mongo is running

I'm using Mac OS X

I've tried to use run-rs with the following command

run-rs -v 4.0.5 --shell -p 28017

and I got the following crash, I have another mongo running already

2019-01-25T16:18:17.179-0200 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-01-25T16:18:17.189-0200 I CONTROL  [initandlisten] MongoDB starting : pid=68440 port=28017 dbpath=/Users/sibelius/Dev/app/./data/28017 64-bit host=sibelius-pro
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten] db version v4.0.5
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten] allocator: system
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten] modules: none
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten] build environment:
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten]     distarch: x86_64
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten]     target_arch: x86_64
2019-01-25T16:18:17.190-0200 I CONTROL  [initandlisten] options: { net: { bindIp: "localhost", port: 28017 }, replication: { replSet: "rs" }, storage: { dbPath: "/Users/sibelius/Dev/app/./data/28017" } }
2019-01-25T16:18:17.192-0200 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Can't assign requested address
2019-01-25T16:18:17.193-0200 I CONTROL  [initandlisten] now exiting
2019-01-25T16:18:17.193-0200 I CONTROL  [initandlisten] shutting down with code:48

    at ChildProcess.<anonymous> (/Users/sibelius/.nvm/versions/node/v10.12.0/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/server.js:404:15)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)

Help Option to display the list of available commands and their descriptions

I would like to be able to run-rs with a --help or -h or run-rs to get the list of available commands. Currently, if I just run run-rs, run-rs executes, but I would rather it displays the list of commands. So running run-rs like below should just show me the list of available commands:
run-rs

or

run-rs --help

or

run-rs -h

Not able to start run-rs

Hi, i'm trying to use run-rs on a project but i'm having the following issue:

$ sudo run-rs -v 4.0.0
Purging database...
Running '/usr/local/lib/node_modules/run-rs/4.0.0/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection 0 to localhost:27017 timed out]
at Pool. (/usr/local/lib/node_modules/run-rs/node_modules/mongodb-core/lib/topologies/server.js:564:11)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection. (/usr/local/lib/node_modules/run-rs/node_modules/mongodb-core/lib/connection/pool.js:317:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket. (/usr/local/lib/node_modules/run-rs/node_modules/mongodb-core/lib/connection/connection.js:257:10)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:420:8)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)

My setup is Linux Mint 19 (Ubuntu 18.04 LTS)

Option to use existing db

Would be nice to be able to add a config option to use existing db. Eg, one used by mongodb instance installed by /usr/local/var/mongodb.

ReplicaSetNoPrimary MongooseServerSelectionError when connecting from inside a Docker container

Environment: MacOS
Issue:
I have a NodeJS application that I want to run inside a Docker container to connect to the replica set using mongoose 5.10.6. I start my replica set with run-rs --dbpath ./data --keep. When I run my application outside of a Docker container node server I connect successfully {"message":"Mongoose successfully connected to mongodb://localhost:27017,localhost:27018,localhost:27019/my-app-dev?replicaSet=rs","level":"info","service”:"my-ap" However, when I run the application inside of a Docker container, I get the following error

info: Mongoose disconnected from mongodb://host.docker.internal:27017,host.docker.internal:27018,host.docker.internal:27019/my-app-dev?replicaSet=rs {"service":"my-app"}
error: Error connecting to the database connect ECONNREFUSED 127.0.0.1:27017 {"service":"my-app","reason":{"type":"ReplicaSetNoPrimary","setName":"rs","maxSetVersion":1,"maxElectionId":"7fffffff0000000000000079","servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logicalSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"commonWireVersion":7},"stack":"MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017\n    at NativeConnection.Connection.openUri (/src/node_modules/mongoose/lib/connection.js:800:32)\n    at /src/node_modules/mongoose/lib/index.js:341:10\n    at /src/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5\n    at new Promise (<anonymous>)\n    at promiseOrCallback (/src/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)\n    at Mongoose.connect (/src/node_modules/mongoose/lib/index.js:340:10)\n    at Object.<anonymous> (/src/index.js:46:21)\n    at Module._compile (internal/modules/cjs/loader.js:1138:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)\n    at Module.load (internal/modules/cjs/loader.js:986:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:879:14)\n    at Module.require (internal/modules/cjs/loader.js:1026:19)\n    at require (internal/modules/cjs/helpers.js:72:18)\n    at Object.<anonymous> (/src/server.js:3:13)\n    at Module._compile (internal/modules/cjs/loader.js:1138:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)"}

Here is my Dockerfile

FROM node:12-alpine

LABEL maintainer="***" version="0.0.1"

WORKDIR /src

# Alpine image does not come with bash
RUN apk add --no-cache bash

COPY package.json /src/
RUN npm install
COPY . /src

EXPOSE 3000

CMD [ "npm", "start"]

Running run-rs -v 4.0.2 starts downloading mongodb

I am finding it odd for run-rs to start downloading mongodb even when mongodb is already installed! Why does it have to download the same thing again when it already exists? The documentation for running run-rs indicates that I can run it with a different version, other than the default mongodb version, by executing the run-rs -v 4.0.2 command, but that is not the case! I am made to go through the whole download process!

Can I use the already installed version of mongodb which supports multi-document transactions without run-rs downloading the whole thing again? This would mean having so many instances of mongodb on my machine which may end-up into unforeseen disaster. Am I missing something?

Unable to start or create replica set with mongodb 4.4.1

Recently I had to brew update && brew upgrade for something, which bumped mongodb-community from 4.2 to 4.4.1. When trying to use run-rs to restart a replica set, I was never able to restart my previous replica set or start a new one (using the command run-rs -k -m -p 27018)

Looking at the source in index.js, I got logs as far as https://github.com/vkarpov15/run-rs/blob/master/index.js#L127, but never made it out of that if block to e.g. https://github.com/vkarpov15/run-rs/blob/master/index.js#L151. Best guess is that the mongodb-topology-manager hasn't been updated since 2019 and something is out of date.

For the time being I was able to resolve this by reverting back to 4.2.

Unable to "npm i -g run-rs"

npm ERR! path /usr/local/lib/node_modules/run-rs/node_modules/detect-libc/bin/detect-libc.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/run-rs/node_modules/detect-libc/bin/detect-libc.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:

Cannot use version 4.2.0

I was trying to use latest version 4.2.0 but when I run run-rs -v 4.2.0 I get the following output error

Downloading MongoDB 4.2.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:100   243    0   243    0     0   1265      0 --:--:-- --:--:-- --:--:--  1265

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Error: Command failed: tar -zxvf mongodb-linux-x86_64-4.2.0.tgz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

    at checkExecSyncError (child_process.js:616:11)
    at execSync (child_process.js:653:13)
    at dl (/home/luismexin/.nvm/versions/node/v10.15.3/lib/node_modules/run-rs/dl.js:51:5)
    at run (/home/luismexin/.nvm/versions/node/v10.15.3/lib/node_modules/run-rs/index.js:80:7)
    at run.next (<anonymous>)
    at onFulfilled (/home/luismexin/.nvm/versions/node/v10.15.3/lib/node_modules/run-rs/node_modules/co/index.js:65:19)
    at /home/luismexin/.nvm/versions/node/v10.15.3/lib/node_modules/run-rs/node_modules/co/index.js:54:5
    at new Promise (<anonymous>)
    at co (/home/luismexin/.nvm/versions/node/v10.15.3/lib/node_modules/run-rs/node_modules/co/index.js:50:10)
    at Object.<anonymous> (/home/luismexin/.nvm/versions/node/v10.15.3/lib/node_modules/run-rs/index.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)

OS: Ubuntu 19.04
Node version 10.15.3

Gets stuck on 'Starting replica set...'

I have followed the instructions given here.

I ran the commands:
npm install run-rs -g
run-rs -v 4.4.0 --shell

But on the second command, although it downloads Mongo successfully, it gets stuck on Starting replica set...

Cannot read property 'toString' of null, on macOS

I just ran run-rs --version 4.0.0 on macOS 10.14.6 and got the output below. Note, I did try stopping the mongodb server that I had running, but this did not change anything.

╰─➤  run-rs --version 4.0.0
Downloading MongoDB 4.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 66.3M  100 66.3M    0     0  10.9M      0  0:00:06  0:00:06 --:--:-- 11.0M
x mongodb-osx-x86_64-4.0.0/README
x mongodb-osx-x86_64-4.0.0/THIRD-PARTY-NOTICES
x mongodb-osx-x86_64-4.0.0/MPL-2
x mongodb-osx-x86_64-4.0.0/GNU-AGPL-3.0
x mongodb-osx-x86_64-4.0.0/LICENSE-Community.txt
x mongodb-osx-x86_64-4.0.0/bin/mongodump
x mongodb-osx-x86_64-4.0.0/bin/mongorestore
x mongodb-osx-x86_64-4.0.0/bin/mongoexport
x mongodb-osx-x86_64-4.0.0/bin/mongoimport
x mongodb-osx-x86_64-4.0.0/bin/mongostat
x mongodb-osx-x86_64-4.0.0/bin/mongotop
x mongodb-osx-x86_64-4.0.0/bin/bsondump
x mongodb-osx-x86_64-4.0.0/bin/mongofiles
x mongodb-osx-x86_64-4.0.0/bin/mongoreplay
x mongodb-osx-x86_64-4.0.0/bin/mongod
x mongodb-osx-x86_64-4.0.0/bin/mongos
x mongodb-osx-x86_64-4.0.0/bin/mongo
x mongodb-osx-x86_64-4.0.0/bin/install_compass
Copied MongoDB 4.0.0 to '/Users/ajmas/npm/lib/node_modules/run-rs/src/4.0.0'
Purging database...
Running '/Users/ajmas/npm/lib/node_modules/run-rs/4.0.0/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
/Users/ajmas/npm/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124
            .toString()
             ^

TypeError: Cannot read property 'toString' of null
    at ChildProcess.<anonymous> (/Users/ajmas/npm/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124:14)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:597:12)

Node version is v10.15.3

Warnings

I see these logged warnings when I start a RS with [email protected] on Windows:

(node:15384) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15384) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:15384) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:15384) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency

Also reported here: #54

Any clean way to remove them?

run-rs nuked my existing databases

I installed this module and used the following command to use my existing databases.

run-rs --mongod --dbpath /usr/local/var/mongodb --host localhost --portStart 27017

When I connect with MongoDB Compass I don't see my existing databases. When I look at the folder where the existing databases were located all the files have been rearranged into subfolders for each instance of the replica set.

How do I recover my existing databases?

Just a question

Hello, is it possible to run a replicat set compose of a single mongodb server?

Thanks

TypeError: Cannot read property 'includes' of undefined when upgraded from 0.6.2 to 0.7.0

Getting the following error when I upgraded the package to 0.7.0

TypeError: Cannot read property 'includes' of undefined
    at /home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/index.js:211:23
    at Generator.throw (<anonymous>)
    at onRejected (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/co/index.js:81:24)
    at tryCatcher (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues (/home/luismexin/.nvm/versions/node/v12.14.1/lib/node_modules/run-rs/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

Starting rs with --keep throws an error

Hey. Great package. Makes life easier.

Right now I've been facing an issue:
run-rs --keep throws an error. Not quite sure what's happening. The error messages are a little difficult to follow and I'm no MongoDb expert.

I'm using the latest version of run-rs.

Also, run-rs works fine and so does run-rs --mongod

:~$ run-rs --keep
Skipping purge
Running '/usr/local/lib/node_modules/run-rs/4.0.12/mongod' [ 27017, 27018, 27019 ]
Restarting replica set...
(node:12679) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12679) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:12679) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:12679) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
Error: failed to start mongod with options [
  '--port=27017',
  '--dbpath=/home/user/data/27017',
  '--bind_ip=localhost',
  '--replSet=rs'
]
2021-06-20T22:23:40.781+0530 I STORAGE  [main] Max cache overflow file size custom option: 0
2021-06-20T22:23:40.783+0530 I CONTROL  [initandlisten] MongoDB starting : pid=12687 port=27017 dbpath=/home/user/data/27017 64-bit host=user
2021-06-20T22:23:40.783+0530 I CONTROL  [initandlisten] db version v4.0.12
2021-06-20T22:23:40.783+0530 I CONTROL  [initandlisten] git version: 5776e3cbf9e7afe86e6b29e22520ffb6766e95d4
2021-06-20T22:23:40.783+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2021-06-20T22:23:40.783+0530 I CONTROL  [initandlisten] modules: none
2021-06-20T22:23:40.784+0530 I CONTROL  [initandlisten] build environment:
2021-06-20T22:23:40.784+0530 I CONTROL  [initandlisten]     distarch: x86_64
2021-06-20T22:23:40.784+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2021-06-20T22:23:40.784+0530 I CONTROL  [initandlisten] options: { net: { bindIp: "localhost", port: 27017 }, replication: { replSet: "rs" }, storage: { dbPath: "/home/user/data/27017" } }
2021-06-20T22:23:40.784+0530 I STORAGE  [initandlisten] Detected data files in /home/user/data/27017 created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2021-06-20T22:23:40.784+0530 I STORAGE  [initandlisten] 
2021-06-20T22:23:40.784+0530 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2021-06-20T22:23:40.784+0530 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-06-20T22:23:40.784+0530 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7390M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2021-06-20T22:23:41.152+0530 E STORAGE  [initandlisten] WiredTiger error (-31802) [1624208021:152541][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 606: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error Raw: [1624208021:152541][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 606: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error
2021-06-20T22:23:41.152+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:152592][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 613: WiredTiger has failed to open its metadata Raw: [1624208021:152592][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 613: WiredTiger has failed to open its metadata
2021-06-20T22:23:41.152+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:152598][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 616: This may be due to the database files being encrypted, being from an older version or due to corruption on disk Raw: [1624208021:152598][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 616: This may be due to the database files being encrypted, being from an older version or due to corruption on disk
2021-06-20T22:23:41.152+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:152604][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 619: You should confirm that you have opened the database with the correct options including all encryption and compression options Raw: [1624208021:152604][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 619: You should confirm that you have opened the database with the correct options including all encryption and compression options
2021-06-20T22:23:41.154+0530 E STORAGE  [initandlisten] WiredTiger error (-31802) [1624208021:154925][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 606: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error Raw: [1624208021:154925][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 606: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error
2021-06-20T22:23:41.154+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:154975][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 613: WiredTiger has failed to open its metadata Raw: [1624208021:154975][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 613: WiredTiger has failed to open its metadata
2021-06-20T22:23:41.154+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:154980][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 616: This may be due to the database files being encrypted, being from an older version or due to corruption on disk Raw: [1624208021:154980][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 616: This may be due to the database files being encrypted, being from an older version or due to corruption on disk
2021-06-20T22:23:41.154+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:154985][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 619: You should confirm that you have opened the database with the correct options including all encryption and compression options Raw: [1624208021:154985][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 619: You should confirm that you have opened the database with the correct options including all encryption and compression options
2021-06-20T22:23:41.157+0530 E STORAGE  [initandlisten] WiredTiger error (-31802) [1624208021:157318][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 606: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error Raw: [1624208021:157318][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 606: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error
2021-06-20T22:23:41.157+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:157369][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 613: WiredTiger has failed to open its metadata Raw: [1624208021:157369][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 613: WiredTiger has failed to open its metadata
2021-06-20T22:23:41.157+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:157375][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 616: This may be due to the database files being encrypted, being from an older version or due to corruption on disk Raw: [1624208021:157375][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 616: This may be due to the database files being encrypted, being from an older version or due to corruption on disk
2021-06-20T22:23:41.157+0530 E STORAGE  [initandlisten] WiredTiger error (0) [1624208021:157379][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 619: You should confirm that you have opened the database with the correct options including all encryption and compression options Raw: [1624208021:157379][12687:0x7fc9cbe6ea40], file:WiredTiger.wt, connection: __wt_btree_tree_open, 619: You should confirm that you have opened the database with the correct options including all encryption and compression options
2021-06-20T22:23:41.158+0530 W STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
2021-06-20T22:23:41.158+0530 W STORAGE  [initandlisten] WiredTiger metadata corruption detected
2021-06-20T22:23:41.158+0530 F STORAGE  [initandlisten] Please read the documentation for starting MongoDB with --repair here: http://dochub.mongodb.org/core/repair
2021-06-20T22:23:41.158+0530 F -        [initandlisten] Fatal Assertion 50944 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 700
2021-06-20T22:23:41.158+0530 F -        [initandlisten] 

***aborting after fassert() failure



    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/run-rs/src/topologyManagerPatch.js:152:13)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

exception in initAndListen std::exception: listen: Address already in use, terminating

Expected Behavior

Replica set should spin up fine with run-rs -v 3.6.0

Current Behavior

After first installing and executing run-rs it downloaded MongoDB 4.0.0 and ran just fine. After killing that command and running run-rs -v 3.6.0 I get the following error:

[diegonetto@localhost ~]$ run-rs -v 3.6.0
Purging database...
Running '/home/diegonetto/.npm-global/lib/node_modules/run-rs/3.6.0/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
Error: failed to start mongod with options --port=27017,--dbpath=/home/diegonetto/data/27017,--bind_ip=localhost,--replSet=rs
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] MongoDB starting : pid=15556 port=27017 dbpath=/home/diegonetto/data/27017 64-bit host=localhost.localdomain
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] db version v3.6.0
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] allocator: tcmalloc
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] modules: none
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] build environment:
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten]     distarch: x86_64
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten]     target_arch: x86_64
2019-04-05T18:18:30.241-0700 I CONTROL  [initandlisten] options: { net: { bindIp: "localhost", port: 27017 }, replication: { replSet: "rs" }, storage: { dbPath: "/home/diegonetto/data/27017" } }
2019-04-05T18:18:30.243-0700 I STORAGE  [initandlisten] 
2019-04-05T18:18:30.243-0700 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-04-05T18:18:30.243-0700 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-04-05T18:18:30.244-0700 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=5491M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-04-05T18:18:30.342-0700 I CONTROL  [initandlisten] 
2019-04-05T18:18:30.342-0700 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-04-05T18:18:30.342-0700 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-04-05T18:18:30.342-0700 I CONTROL  [initandlisten] 
2019-04-05T18:18:30.349-0700 I STORAGE  [initandlisten] createCollection: local.startup_log with no UUID.
2019-04-05T18:18:30.368-0700 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/home/diegonetto/data/27017/diagnostic.data'
2019-04-05T18:18:30.368-0700 I STORAGE  [initandlisten] createCollection: local.me with no UUID.
2019-04-05T18:18:30.387-0700 I STORAGE  [initandlisten] createCollection: local.replset.minvalid with no UUID.
2019-04-05T18:18:30.405-0700 I REPL     [initandlisten] Did not find local voted for document at startup.
2019-04-05T18:18:30.405-0700 I REPL     [initandlisten] Did not find local Rollback ID document at startup. Creating one.
2019-04-05T18:18:30.405-0700 I STORAGE  [initandlisten] createCollection: local.system.rollback.id with no UUID.
2019-04-05T18:18:30.424-0700 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2019-04-05T18:18:30.425-0700 I STORAGE  [initandlisten] exception in initAndListen std::exception: listen: Address already in use, terminating
2019-04-05T18:18:30.425-0700 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-04-05T18:18:30.425-0700 I REPL     [initandlisten] shutdown: removing all drop-pending collections...
2019-04-05T18:18:30.425-0700 I REPL     [initandlisten] shutdown: removing checkpointTimestamp collection...
2019-04-05T18:18:30.425-0700 I REPL     [initandlisten] shutting down replication subsystems
2019-04-05T18:18:30.425-0700 I FTDC     [initandlisten] Shutting down full-time diagnostic data capture
2019-04-05T18:18:30.425-0700 I STORAGE  [initandlisten] WiredTigerKVEngine shutting down
2019-04-05T18:18:30.746-0700 I STORAGE  [initandlisten] WiredTiger message [1554513510:746560][15556:0x7fb42e4b09c0], txn-recover: Main recovery loop: starting at 1/19840
2019-04-05T18:18:30.846-0700 I STORAGE  [initandlisten] WiredTiger message [1554513510:846554][15556:0x7fb42e4b09c0], txn-recover: Recovering log 1 through 2
2019-04-05T18:18:30.906-0700 I STORAGE  [initandlisten] WiredTiger message [1554513510:906160][15556:0x7fb42e4b09c0], txn-recover: Recovering log 2 through 2
2019-04-05T18:18:31.032-0700 I STORAGE  [initandlisten] shutdown: removing fs lock...
2019-04-05T18:18:31.032-0700 I CONTROL  [initandlisten] now exiting
2019-04-05T18:18:31.032-0700 I CONTROL  [initandlisten] shutting down with code:100

    at ChildProcess.<anonymous> (/home/diegonetto/.npm-global/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/server.js:404:15)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

This particular line 2019-04-05T18:18:30.425-0700 I STORAGE [initandlisten] exception in initAndListen std::exception: listen: Address already in use, terminating caused me to check two things:

  1. Were there any lingering MongoDB processes active? sudo ps aux | grep mongo
  2. Was there anything bound to those ports? ss -nlput

The answer to both questions above was no. If I execute run-rs and then run the commands from 1 & 2, I get the expected:

[diegonetto@localhost ~]$ ss -nlput
Netid          State             Recv-Q            Send-Q                        Local Address:Port                        Peer Address:Port                                                         
.
.                                   [::]:5353                                [::]:*                                                            
tcp            LISTEN            0                 128                               127.0.0.1:27017                            0.0.0.0:*               users:(("mongod",pid=15958,fd=10))           
tcp            LISTEN            0                 128                               127.0.0.1:27018                            0.0.0.0:*               users:(("mongod",pid=15993,fd=10))           
tcp            LISTEN            0                 128                               127.0.0.1:27019                            0.0.0.0:*               users:(("mongod",pid=16024,fd=10))           
.
.                                  [::1]:631                                 [::]:*                            

And

[diegonetto@localhost ~]$ sudo ps aux | grep mongo
[sudo] password for diegonetto: 
diegone+ 15958  2.7  0.6 1391828 75100 pts/1   Sl+  18:26   0:01 /home/diegonetto/.npm-global/lib/node_modules/run-rs/4.0.6/mongod --port=27017 --dbpath=/home/diegonetto/data/27017 --bind_ip=localhost --replSet=rs
diegone+ 15993  2.8  0.6 1295124 74780 pts/1   Sl+  18:26   0:01 /home/diegonetto/.npm-global/lib/node_modules/run-rs/4.0.6/mongod --port=27018 --dbpath=/home/diegonetto/data/27018 --bind_ip=localhost --replSet=rs
diegone+ 16024  2.9  0.6 1327900 74424 pts/1   Sl+  18:26   0:01 /home/diegonetto/.npm-global/lib/node_modules/run-rs/4.0.6/mongod --port=27019 --dbpath=/home/diegonetto/data/27019 --bind_ip=localhost --replSet=rs

Neither of the above show up once I kill the run-rs command, yet run-rs -v 3.6.0 still errors out.

Environment:

I'm running Fedora 29 64bit within VirtualBox

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.