Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
flora-cluster
Advanced tools
Simple cluster manager module with status tracking for HTTP servers
Simple cluster manager module with status tracking for HTTP servers.
Flora requires Node.js v10 or higher.
The master process will start 3 workers and restarts them on crashes:
const path = require('path');
const { Master } = require('flora-cluster');
const master = new Master({
exec: path.join(__dirname, 'worker.js'),
workers: 3 // defaults to os.cpus().length
});
master.run();
const { createServer } = require('http');
const { Worker } = require('flora-cluster');
const worker = new Worker();
const httpServer = createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
});
worker.attach(httpServer);
worker.on('close', () => httpServer.close());
httpServer.listen(3000);
httpServer.on('listening', () => worker.ready());
You can retrieve an aggregated status from all workers from any worker:
console.log(await worker.serverStatus());
See "example" folder.
You can perform extended tests in your worker on startup - just exit if something fails. On a graceful reload, the master process will cancel the reload and shutdown all workers of the new generation. Reload is assumed to be successful when all workers called their ready() function. The old generation of workers is shutdown not before all new workers are up and running.
Aggregated status over all workers can be requested from inside a worker and from the master process. So it is possible to integrate the status into your application. Another possibility is to start a HTTP server inside the master process on a management port for those requests.
FAQs
Simple cluster manager module with status tracking for HTTP servers
The npm package flora-cluster receives a total of 1 weekly downloads. As such, flora-cluster popularity was classified as not popular.
We found that flora-cluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.