
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@clusic/cluster
Advanced tools
集群启动模块
npm i @clusic/cluster
const path = require('path');
const master = require('@clusic/cluster');
const app = new master({
cwd: __dirname,
env: 'dev',
agents: ['agent', 'test', 'abc'],
framework: path.resolve(__dirname, 'framework'),
// max: 2
});
app.createServer().catch(e => app.kill());
Arguments:
/**
* IPC Master process
*
* OPTIONS:
* @param socket {boolean} <default: false> 是否开启socket模式
* @param port {number} <default: 8080> 服务启动端口
* @param cwd {string} <default: process.cwd()> 服务运行基址
* @param env {string} <default: 'development'> 环境变量
* @param debug {boolean|string} <default: false> 是否开启调试以及调试模式 eg: 'inspect-brk'
* @param framework {string} <default: __dirname> 服务启动框架
* @param max {Number} <default: os.cpus().length> 最大worker进程个数
* @type {module.MasterProcess}
*/
框架原型
module.exports = class Application {
constructor(app, data) {
this.data = data;
this.app = app;
}
// 进程创建周期
async processCreate() {
await new Promise((resolve, reject) => {
setTimeout(() => {
console.log('worker processWillCreate', Date.now());
// if (process.pid % 2 === 0) {
// return reject(new Error('test error'))
// }
resolve();
}, 2000);
});
}
// 消息接收函数
processMessage(msg, socket) {
if (msg.action === 'cluster:ready') {
console.log('all ready in worker ' + process.pid);
}
// console.log('message', msg);
}
//进程销毁周期
async processDestroy() {
await new Promise((resolve, reject) => {
setTimeout(() => {
console.log('worker processDestroy', Date.now());
resolve();
}, 2000);
});
}
};
FAQs
The cluster model of clusic
The npm package @clusic/cluster receives a total of 23 weekly downloads. As such, @clusic/cluster popularity was classified as not popular.
We found that @clusic/cluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.