
Research
/Security News
60 Malicious Ruby Gems Used in Targeted Credential Theft Campaign
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Dead-simple one-liner for clustered Node.js apps.
Forks N workers and creates new ones if they go down. Correctly handles signals from the OS.
const throng = require('throng')
throng(id => console.log(`Started worker ${id}`))
$ node example
Started worker 1
Started worker 2
Started worker 3
Started worker 4
$ npm install --save throng
throng(workerStartFunction)
throng({ worker: workerStartFunction, count: 3 })
throng({
master: masterStartFunction,
worker: workerStartFunction,
count: 16,
grace: 1000
})
(for cleaning up before disconnecting a worker on a SIGTERM, for instance)
throng({ worker })
function worker(id, disconnect) {
console.log(`Started worker ${id}`)
process.on('SIGTERM', () => {
console.log(`Worker ${id} exiting (cleanup here)`)
disconnect()
})
})
throng({
master: masterFn, // Fn to call in master process (can be async)
worker: workerFn, // Fn to call in cluster workers (can be async)
count: 4, // Number of workers (cpu count)
lifetime: Infinity, // Min time to keep cluster alive (ms)
grace: 5000, // Grace period between signal and hard shutdown (ms)
signals: ['SIGTERM', 'SIGINT'] // Signals that trigger a shutdown (proxied to workers)
})
const throng = require('throng')
throng({ master, worker, count: 4 })
// This will only be called once
function master() {
console.log('Started master')
process.once('beforeExit', () => {
console.log('Master cleanup.')
})
}
// This will be called four times
function worker(id, disconnect) {
console.log(`Started worker ${ id }`)
process.once('SIGTERM', shutdown)
process.once('SIGINT', shutdown)
function shutdown() {
console.log(`Worker ${ id } cleanup.`)
disconnect()
}
}
$ node example-complex.js
Started master
Started worker 1
Started worker 3
Started worker 2
Started worker 4
^C
Worker 1 cleanup.
Worker 3 cleanup.
Worker 2 cleanup.
Worker 4 cleanup.
Master cleanup.
Throng forks replacements for workers that crash so your cluster can continue working through failures.
$ node example-crashy.js
-1--2--3--4--2--1--3--4--crash!--1--3--4--crash!--5--3--4--6--5--3--4--crash!--6--crash!--crash!--7--6--8--9--7--6--8--9--crash!--7--6--9--10--7--6--9--10--crash!--7--9--10--11--7--crash!--9--crash!--7--12--9--13--crash!--12--9--crash!--crash!--crash!--14--crash!--12--15--crash!--14--18--15--19--14--18--15--crash!--19--14--crash!--15--20--14--21--15--20--14--21--15--20--14--21--15--20--14--21--15-
$ docker-compose run --rm dev
node@docker:/home/app$ npm test
FAQs
A simple worker-manager for clustered apps
The npm package throng receives a total of 34,410 weekly downloads. As such, throng popularity was classified as popular.
We found that throng 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
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.