egg-cluster
Advanced tools
Comparing version 2.3.0 to 2.4.0-beta.0
@@ -27,3 +27,3 @@ 'use strict'; | ||
const debug = require('util').debuglog('egg-cluster'); | ||
const debug = require('util').debuglog('egg-cluster:agent_worker'); | ||
const ConsoleLogger = require('egg-logger').EggConsoleLogger; | ||
@@ -30,0 +30,0 @@ const consoleLogger = new ConsoleLogger({ level: process.env.EGG_AGENT_WORKER_LOGGER_LEVEL }); |
@@ -19,4 +19,5 @@ 'use strict'; | ||
const os = require('os'); | ||
const fs = require('fs'); | ||
const debug = require('util').debuglog('egg-cluster'); | ||
const debug = require('util').debuglog('egg-cluster:app_worker'); | ||
const ConsoleLogger = require('egg-logger').EggConsoleLogger; | ||
@@ -42,2 +43,9 @@ const consoleLogger = new ConsoleLogger({ | ||
let reusePort = options.reusePort = options.reusePort || listenConfig.reusePort; | ||
if (reusePort && os.platform() !== 'linux') { | ||
// Currently only linux is supported | ||
reusePort = false; | ||
debug('platform %s is not support currently, set reusePort to false', os.platform()); | ||
} | ||
AppWorker.send({ | ||
@@ -126,6 +134,17 @@ to: 'master', | ||
} | ||
const args = [ port ]; | ||
if (listenConfig.hostname) args.push(listenConfig.hostname); | ||
debug('listen options %s', args); | ||
server.listen(...args); | ||
if (reusePort) { | ||
const listenOptions = { port, reusePort }; | ||
if (listenConfig.hostname) { | ||
listenOptions.host = listenConfig.hostname; | ||
} | ||
debug('listen options %s', listenOptions); | ||
server.listen(listenOptions); | ||
} else { | ||
const args = [ port ]; | ||
if (listenConfig.hostname) { | ||
args.push(listenConfig.hostname); | ||
} | ||
debug('listen options %s', args); | ||
server.listen(...args); | ||
} | ||
} | ||
@@ -132,0 +151,0 @@ if (debugPortServer) { |
@@ -37,2 +37,3 @@ 'use strict'; | ||
* - {Number} [port] listening port, default to 7001(http) or 8443(https) | ||
* - {Boolean} [reusePort] setting `reusePort` to `true` allows multiple sockets on the same host to bind to the same port. Incoming connections are distributed by the operating system to listening sockets. This option is available only on some platforms, such as Linux 3.9+, DragonFlyBSD 3.6+, FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+. **Default:** `false`. | ||
* - {Number} [debugPort] listening a debug port on http protocol | ||
@@ -39,0 +40,0 @@ * - {Object} [https] https options, { key, cert, ca }, full path |
@@ -15,2 +15,3 @@ 'use strict'; | ||
port: options.https ? 8443 : null, | ||
reusePort: false, | ||
workers: null, | ||
@@ -72,3 +73,2 @@ plugins: null, | ||
if (isDebug) options.isDebug = isDebug; | ||
return options; | ||
@@ -75,0 +75,0 @@ }; |
{ | ||
"name": "egg-cluster", | ||
"version": "2.3.0", | ||
"version": "2.4.0-beta.0", | ||
"description": "cluster manager for egg", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"cov": "egg-bin cov --prerequire --timeout 100000 --ts false", | ||
"ci": "npm run lint && npm run cov", | ||
"ci": "npm run lint && node test/reuseport_cluster.js && npm run cov", | ||
"contributor": "git-contributor" | ||
@@ -14,0 +14,0 @@ }, |
@@ -74,14 +74,4 @@ # egg-cluster | ||
<!-- GITCONTRIBUTOR_START --> | ||
## Contributors | ||
|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/227713?v=4" width="100px;"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src="https://avatars.githubusercontent.com/u/6897780?v=4" width="100px;"/><br/><sub><b>killagu</b></sub>](https://github.com/killagu)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>| | ||
| :---: | :---: | :---: | :---: | :---: | :---: | | ||
|[<img src="https://avatars.githubusercontent.com/u/5243774?v=4" width="100px;"/><br/><sub><b>ngot</b></sub>](https://github.com/ngot)<br/>|[<img src="https://avatars.githubusercontent.com/u/19908330?v=4" width="100px;"/><br/><sub><b>hyj1991</b></sub>](https://github.com/hyj1991)<br/>|[<img src="https://avatars.githubusercontent.com/u/5856440?v=4" width="100px;"/><br/><sub><b>whxaxes</b></sub>](https://github.com/whxaxes)<br/>|[<img src="https://avatars.githubusercontent.com/u/2170848?v=4" width="100px;"/><br/><sub><b>iyuq</b></sub>](https://github.com/iyuq)<br/>|[<img src="https://avatars.githubusercontent.com/u/2972143?v=4" width="100px;"/><br/><sub><b>nightink</b></sub>](https://github.com/nightink)<br/>|[<img src="https://avatars.githubusercontent.com/u/2160731?v=4" width="100px;"/><br/><sub><b>mansonchor</b></sub>](https://github.com/mansonchor)<br/>| | ||
|[<img src="https://avatars.githubusercontent.com/u/10825163?v=4" width="100px;"/><br/><sub><b>ImHype</b></sub>](https://github.com/ImHype)<br/>|[<img src="https://avatars.githubusercontent.com/u/1207064?v=4" width="100px;"/><br/><sub><b>gxcsoccer</b></sub>](https://github.com/gxcsoccer)<br/>|[<img src="https://avatars.githubusercontent.com/u/1763067?v=4" width="100px;"/><br/><sub><b>waitingsong</b></sub>](https://github.com/waitingsong)<br/>|[<img src="https://avatars.githubusercontent.com/u/7581901?v=4" width="100px;"/><br/><sub><b>sjfkai</b></sub>](https://github.com/sjfkai)<br/>|[<img src="https://avatars.githubusercontent.com/u/26563778?v=4" width="100px;"/><br/><sub><b>ahungrynoob</b></sub>](https://github.com/ahungrynoob)<br/>|[<img src="https://avatars.githubusercontent.com/u/3230673?v=4" width="100px;"/><br/><sub><b>qingdengyue</b></sub>](https://github.com/qingdengyue)<br/>| | ||
[<img src="https://avatars.githubusercontent.com/u/16320597?v=4" width="100px;"/><br/><sub><b>wenjiasen</b></sub>](https://github.com/wenjiasen)<br/>|[<img src="https://avatars.githubusercontent.com/u/418820?v=4" width="100px;"/><br/><sub><b>czy88840616</b></sub>](https://github.com/czy88840616)<br/>|[<img src="https://avatars.githubusercontent.com/u/9213756?v=4" width="100px;"/><br/><sub><b>gxkl</b></sub>](https://github.com/gxkl)<br/> | ||
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jun 03 2024 10:59:15 GMT+0800`. | ||
<!-- GITCONTRIBUTOR_END --> | ||
[![contributors](https://contrib.rocks/image?repo=eggjs/egg-cluster&max=240&columns=26)](https://github.com/eggjs/egg-cluster/graphs/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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
1755
59979
1
77