
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
cluster fork and restart easy way.
uncaughtException
eventnpm install cfork
import util from 'node:util';
import { cfork } from 'cfork';
const clusterWorker = cfork({
exec: '/your/app/worker.js',
// slaves: ['/your/app/slave.js'],
// count: require('os').cpus().length,
}).on('fork', worker => {
console.warn('[%s] [worker:%d] new worker start', Date(), worker.process.pid);
})
.on('disconnect', worker => {
console.warn('[%s] [master:%s] wroker:%s disconnect, exitedAfterDisconnect: %s, state: %s.',
Date(), process.pid, worker.process.pid, worker.exitedAfterDisconnect, worker.state);
})
.on('exit', (worker, code, signal) => {
const exitCode = worker.process.exitCode;
const err = new Error(util.format('worker %s died (code: %s, signal: %s, exitedAfterDisconnect: %s, state: %s)',
worker.process.pid, exitCode, signal, worker.exitedAfterDisconnect, worker.state));
err.name = 'WorkerDiedError';
console.error('[%s] [master:%s] wroker exit: %s', Date(), process.pid, err.stack);
})
// if you do not listen to this event
// cfork will output this message to stderr
.on('unexpectedExit', (worker, code, signal) => {
// logger what you want
})
// emit when reach refork times limit
.on('reachReforkLimit', () => {
// do what you want
});
// if you do not listen to this event
// cfork will listen it and output the error message to stderr
process.on('uncaughtException', err => {
// do what you want
});
// if you want to dynamically disable refork, you can call the setDisableRefork, priority over the refork parameter
cfork.setDisableRefork(clusterWorker, true);
const { cfork } = require('cfork');
os.cpus().length
true
duration
, default is 60
60000
, one minute (so, the refork times
< limit / duration
)running_under_istanbul
env set, default is false
Made with contributors-img.
2.0.0 (2024-12-15)
part of https://github.com/eggjs/egg/issues/3644
https://github.com/eggjs/egg/issues/5257
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->New Features
Introduced a new GitHub Actions workflow for automated package publishing.
Added TypeScript configuration to enhance type safety and modern JavaScript compatibility.
Updates
Enhanced README with installation and usage examples for ESM and TypeScript.
Updated package.json to reflect new module structure and dependencies.
Improved .gitignore to exclude additional temporary files and directories.
Bug Fixes
Improved .gitignore to exclude additional temporary files and directories.
Removals
Removed outdated JavaScript files and configurations in favor of CommonJS and TypeScript standards.
FAQs
cluster fork and restart easy way
The npm package cfork receives a total of 17,431 weekly downloads. As such, cfork popularity was classified as popular.
We found that cfork demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.