mongo-server-manager

0.1.2 • Public • Published

Install

npm install mongo-server-manager

Test

require coffee-script and mocha to be installed.

npm test

Usage

I use this module to manage a mongod instance for a desktop application as an embeded database.

# all option is critical
# though port and host will fallback to 27017 and localhost
# if not provided.
service = manager.createInstance {
    logPath:"./test/db/log"
    ,pidPath:"./test/db/mongod.pid"
    ,dbPath:"./test/db"
    ,port:12345
    ,host:"localhost"
    ,binPath:"mongod"
}
service.isDaemonUp (err,pid)->
    # if daemonis up return pid
    # or pid is false
    if not pid
        service.start (err)->
        # shouldn't has err
            service.isOnline (err,online)->
            # online should be true 
        service.stop (err)->
            process.exit()

Difference between isDaemonUp and isOnline is that isDaemonUp will only check the pid file and corresponding process is running, wile isOnline will only try to connection to the host and port and make sure it's a mongodb service.

Readme

Keywords

Package Sidebar

Install

npm i mongo-server-manager

Weekly Downloads

0

Version

0.1.2

License

ISC

Last publish

Collaborators

  • nstal