Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-cluster

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-cluster - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

47

lib/http.js

@@ -5,3 +5,2 @@

var http = require('http')
var domain = require('domain')
var cluster = require('cluster')

@@ -15,6 +14,6 @@

var server = http.createServer()
server.on('request', handler)
server.on('request', callback)
server.on('checkContinue', function (req, res) {
req.checkContinue = true
handler(req, res)
callback(req, res)
})

@@ -37,34 +36,16 @@

var closing = false
process.on('SIGTERM', close)
process.on('SIGINT', close)
process.on('SIGTERM', function () {
close(0)
})
process.on('SIGINT', function () {
close(0)
})
process.on('uncaughtException', function (err) {
console.error(err.stack)
close(1)
})
process.on('exit', function () {
console.log('process exiting')
console.log('exiting worker %s', cluster.worker.id)
})
// http://nodejs.org/api/domain.html
function handler(req, res) {
var d = domain.create()
d.on('error', function (err) {
console.error(err.stack)
close(1)
try {
res.statusCode = 500
res.setHeader('Content-Type', 'text/plain')
res.end('Oops, sorry!')
} catch (err) {
console.error(err.stack)
}
})
d.add(req)
d.add(res)
d.run(function () {
callback(req, res)
})
}
function close(code) {

@@ -77,3 +58,3 @@ if (closing) return

var killtimer = setTimeout(function () {
process.exit(code || 0)
process.exit(code)
}, 30000)

@@ -80,0 +61,0 @@

{
"name": "koa-cluster",
"description": "Koa clustering and domain-based error handling utility",
"version": "0.1.0",
"version": "0.2.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Jonathan Ong",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc