Monogamous
Only one instance of an app at a time.
Install
npm install monogamous
Usage (using Electron as an example)
Decorating main process entrypoint
//index.js booter = /*** this presumes your `app.on('ready')` is inside your boot method*/booterbooterbooter booter
Inside main process entrypoint
//index.js booter = booterbooterbooter //electron's ready event gets it goingapp
Events
boot
: raised if an instance is not running. Your app may start up pristine herereboot
: another instance was attempted.end
: a call toend()
shutdown the instance server
boot
and reboot
events receive an merged arguments object merging the following inputs,
in order of precedence:
- args passed to monogamous creation; eg
monogamous({ sock: 'foo'}, {these:'arepassedthru'})
- process argv , hashed (using minimist)
- args passed to
boot
; egmono.boot({ these:'arealsopassedthru'})
API
Monogamous Factory
//only the 'sock' property is required to name your socketlet booter =
Instance Methods
boot([args])
: {Function} tries to connect tosock
;failure to connect means an instance is runningend()
: {Function} closes socket server