npm install ctd
ctd
=======
this project was fork the package of cfork, and rewrite by ts.
we found cfork can not fork different worker by env
cluster fork and restart easy way.
* Easy fork with worker file path
* Handle worker restart, even it was exit unexpected.
* Auto error log process uncaughtException event
* set envs, worker count is length of envs ,and every worker's env different. if worker was exit because of configFile, will not refork.
bash
$ npm install ctd --save
`
Usage
$3
`bash
// start your nodejs app
ctd start app.js
// stop your nodejs app
ctd stop
`
$3
options can be an object or a file(config path), you can edit content of your config file and it will work 1 minute later
the file name is .config.json at your app baseDir
- name: your app name,default your package.json name
- exec : exec file path
- args : exec arguments
- count : fork worker nums, default is os.cpus().length
- duration: default is 60000, one minute (so, the refork times < limit / duration)
- env: attach some environment variable key-value pairs to the worker / slave process, default to an empty object.
- model: default cluster,you can set fork
- evns: if you want every worker has different env config ,you can set this field, default is [].example, envs:[{name:1},{name:2}]
- clusterModel:
- 'both':every worker has same evn config
- 'each':every worker has different evn config
- callback: when the worker was exit ,callback` will be wake up