boot single-instance application
npm install monogamous> Only one instance of an app at a time.


npm install monogamous
#### Decorating main process entrypoint
``js
//index.js
import monogamous from 'monogamous'
import main from './main' //main process app stuff
import app from 'app'
booter = monogamous({ sock: 'myapp'}, { other: 'args'})
/**
* this presumes your app.on('ready') is inside your boot method
*/
booter.on('boot', main.boot.bind(main))
booter.on('reboot', main.reboot.bind(main))
booter.on('error', function(err) { console.error('ops', err) })
booter.boot({ more: 'args'})
`
#### Inside main process entrypoint
`js
//index.js
import monogamous from 'monogamous'
import main from './main' //main process app stuff
import app from 'app'
booter = monogamous({ sock: 'myapp'}, { other: 'args'})
booter.on('boot', main.boot.bind(main))
booter.on('reboot', main.reboot.bind(main))
booter.on('error', function(err) { console.error('ops', err) })
//electron's ready event gets it going
app.on('ready', booter.boot.bind(booter))
`
- boot : raised if an instance is not running. Your app may start up pristine herereboot
- : another instance was attempted.end
- : a call to end() 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'})boot
- process argv , hashed (using minimist)
- args passed to ; eg mono.boot({ these:'arealsopassedthru'})
Monogamous Factory
`js
//only the 'sock' property is required to name your socket
let booter = monogamous({ sock: 'keepitsimple' }, [other args...])
`
Instance Methods
- boot([args]) : {Function} tries to connect to sock;failure to connect means an instance is runningend()` : {Function} closes socket server
-