ctd

2.0.3 • Public • Published

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.

Install

$ npm install ctd --save

Usage

Example

// start your nodejs app
ctd start app.js

// stop your nodejs app
ctd stop

Options

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

Change log

  • 2021.9.7
    • update readme file
    • update error of config env types

Package Sidebar

Install

npm i ctd

Weekly Downloads

1

Version

2.0.3

License

MIT

Unpacked Size

43.1 kB

Total Files

11

Last publish

Collaborators

  • tong3jie