
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
cluster-magic
Advanced tools
run multi-threaded node.js network applications using the native cluster module
run multi-threaded node.js network applications using the native cluster module
sigterm
sighup
$ npm install cluster-magic --save
$ yarn add cluster-magic
A working snippet is available in the examples directory. Just run node examples/startup.js
File: startup.js
Initializes the cluster application
const _cluster = require('cluster-magic');
const _app = require('./application.js');
// start the clustered app (8 workers)
_cluster.init(_app, {
numWorkers: 8
});
File: application.js
Your socket based application which should be multiplexed
const net = require('net');
function startup(){
const server = net.createServer((socket) => {
// connections never end
});
server.listen(8000);
}
module.exports = {
// init hook
init: startup
};
To hot-restart (zero downtime) an application, just send a SIGHUP to the master process. This spawns new workers and disconnects all current workers from the cluster-proxy
Example
# send SIGHUP to process 12345
kill -HUP 12345
cluster-magic comes with as simple delayed-restart policy which suppresses infinite restart loops.
counter*200ms
to avoid infinite restart loops on internal application errors.
Well..this is may not what you expect from a "clustered application" but such an error requires that a manual fix will take place by the operations team (_logger.alert event is triggerd which SHOULD be observed)To specify the number of workers you can easily pass the environment variable NUM_WORKERS
to the nodejs process. Default is set to num_cpus*2
cluster-magic is OpenSource and licensed under the Terms of The MIT License (X11) - your're welcome to contribute
FAQs
run multi-threaded node.js network applications using the native cluster module
The npm package cluster-magic receives a total of 0 weekly downloads. As such, cluster-magic popularity was classified as not popular.
We found that cluster-magic 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.