think-cluster
Advanced tools
Comparing version 1.4.2 to 1.5.0
@@ -138,4 +138,4 @@ const cluster = require('cluster'); | ||
server.listen(this.options.port, this.options.host, () => { | ||
this.forkWorkers().then(() => { | ||
deferred.resolve(); | ||
this.forkWorkers().then(data => { | ||
deferred.resolve(data); | ||
}); | ||
@@ -146,7 +146,29 @@ }); | ||
/** | ||
* send inspect port | ||
* @param {Worker} worker | ||
*/ | ||
sendInspectPort(worker) { | ||
const inspect = process.execArgv.some(item => item.indexOf('--inspect') >= 0); | ||
if (!inspect) return; | ||
const spawnargs = worker.process.spawnargs; | ||
let port; | ||
spawnargs.some(item => { | ||
let match; | ||
if (item.indexOf('--inspect') >= 0 && (match = item.match(/\d+/))) { | ||
port = match[0]; | ||
} | ||
}); | ||
if (port) { | ||
process.send({act: 'inspectPort', port}); | ||
} | ||
} | ||
/** | ||
* start server, support sticky | ||
*/ | ||
startServer() { | ||
if (!this.options.sticky) return this.forkWorkers(); | ||
return this.createServer(); | ||
const promise = !this.options.sticky ? this.forkWorkers() : this.createServer(); | ||
return promise.then(data => { | ||
this.sendInspectPort(data[0].worker); | ||
return data; | ||
}); | ||
} | ||
@@ -153,0 +175,0 @@ } |
{ | ||
"name": "think-cluster", | ||
"description": "Cluster manage for ThinkJS", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"author": { | ||
@@ -12,3 +12,4 @@ "name": "welefen", | ||
"test-cov": "nyc ava test/mock-test/ && nyc report --reporter=html", | ||
"lint": "eslint ./lib/ index.js" | ||
"lint": "eslint ./lib/ index.js", | ||
"prepublish": "npm test" | ||
}, | ||
@@ -15,0 +16,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
2
2
19997
11
618