cluster.setupMaster([settings])
setupMaster
is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings
.
Note that:
- any settings changes only affect future calls to
.fork()
and have no effect on workers that are already running - The only attribute of a worker that cannot be set via
.setupMaster()
is theenv
passed to.fork()
- the defaults above apply to the first call only, the defaults for later calls is the current value at the time of
cluster.setupMaster()
is called
Example:
1 2 3 4 5 6 7 8 9 10 11 12 | const cluster = require( 'cluster' ); cluster.setupMaster({ exec: 'worker.js' , args: [ '--use' , 'https' ], silent: true }); cluster.fork(); // https worker cluster.setupMaster({ exec: 'worker.js' , args: [ '--use' , 'http' ] }); cluster.fork(); // http worker |
This can only be called from the master process.
Please login to continue.