Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egg-bin@6,默认端口覆盖了 config.default.js 中配置的端口 #250

Closed
JarryChung opened this issue Jan 29, 2024 · 4 comments · Fixed by #251
Closed

egg-bin@6,默认端口覆盖了 config.default.js 中配置的端口 #250

JarryChung opened this issue Jan 29, 2024 · 4 comments · Fixed by #251
Assignees

Comments

@JarryChung
Copy link
Contributor

问题描述

img_v3_027i_493fd4d1-0b8a-4689-a7cb-631ef0d3f22g
如上图,egg-bin@4egg-bin@5 中,当 detect 到的端口与 defaultPort 一致时,将不会赋值给 argv.port,导致 argv.port 为空,进而用了 config.default.js 里面配置的 port

image
如上图,在 egg-bin@6 中,任何情况都会赋值 this.port,也就意味着不会使用到 config.default.js 中配置的 port

与 6 版本相比,4/5 看起来是 bug 逻辑,但表现上符合业务预期。6 是正常逻辑,但表现上不符合业务预期。

期望

  1. 麻烦帮忙确认下上述理解是否正确;
  2. 能否调整端口获取的优先级为:--port > config 文件 > EGG_BIN_DEFAULT_PORT > 7001;
  3. 建议以何种方式管理生产环境、开发环境的 port,分开管理还是集中管理?业务上,在不同环境的 port 是一样的。

致谢!

JarryChung pushed a commit to JarryChung/egg-bin that referenced this issue Jan 29, 2024
@fengmk2
Copy link
Member

fengmk2 commented Jan 29, 2024

@JarryChung 可以来个 pr 修复一下,恢复跟之前的版本逻辑一致

@JarryChung
Copy link
Contributor Author

JarryChung commented Jan 29, 2024

@fengmk2 我改成了这个逻辑,PR 中的详细内容还没写,可以的话麻烦先帮忙看下逻辑是否 OK,晚点空了我再补充下测试用例及详细说明。

概述:调整了获取端口的优先级:--port > config 文件 > EGG_BIN_DEFAULT_PORT > 7001

@JarryChung
Copy link
Contributor Author

@fengmk2 已添加测试用例,已在文档中注明获取端口顺序,已补充 PR 说明

@fengmk2
Copy link
Member

fengmk2 commented Feb 1, 2024

@JarryChung PR 很完善!今天会合并发布

fengmk2 pushed a commit that referenced this issue Feb 1, 2024
Adjust the order in which ports are obtained:option `--port` > [_egg.js_
configuration](https://www.eggjs.org/basics/config) `config/config.*.js`
> `process.env.EGG_BIN_DEFAULT_PORT` > 7001 > other available ports.


![image](https://github.com/eggjs/egg-bin/assets/35088591/ab8ffafd-c3f3-414b-a46e-a0a8fb897a17)

closes #250

---------

Co-authored-by: tiga <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants