Conversation
- export this.child - support customize stdout and stderr
| const envPath = env.PATH || env.Path; | ||
| if (envPath) { | ||
| // for nodeinstall | ||
| envPath = path.join(baseDir, 'node_modules/.bin') + path.delimiter + envPath; |
There was a problem hiding this comment.
不是把 node_modules 里面的 node 加入到环境变量么?
There was a problem hiding this comment.
之前想过一种,调用 nodeinstall 下载一个 node 版本,然后 app 里面 print 下,但麻烦就放弃了。
Codecov Report
@@ Coverage Diff @@
## master #8 +/- ##
=========================================
- Coverage 97.72% 97.7% -0.02%
=========================================
Files 6 6
Lines 132 131 -1
=========================================
- Hits 129 128 -1
Misses 3 3
Continue to review full report at Codecov.
|
test/start.test.js
Outdated
| let result = yield httpclient.request('http://127.0.0.1:7001/env'); | ||
| assert(result.data.toString() === 'pre, true'); | ||
| result = yield httpclient.request('http://127.0.0.1:7001/path'); | ||
| assert(result.data.toString().match(new RegExp(`^${fixturePath}/node_modules/.bin:`))); |
There was a problem hiding this comment.
: 这个改为 path.delimiter 吧,万一后面支持 win
|
这个用例 windows 是不是跑不起来 |
lib/cmd/start.js
Outdated
| function* getRotatelog(logDir) { | ||
| const stdoutPath = path.join(logDir, 'master-stdout.log'); | ||
| const stderrPath = path.join(logDir, 'master-stderr.log'); | ||
| getFrameworkPath(params) { |
There was a problem hiding this comment.
* getFrameworkPath,这种一般都要去检查文件啥的吧, utils 里面是用 sync 么?
|
@atian25 过了 |
|
|
||
| const env = context.env; | ||
| env.HOME = HOME; | ||
| env.NODE_ENV = 'production'; |
lib/cmd/start.js
Outdated
| function* getRotatelog(logDir) { | ||
| const stdoutPath = path.join(logDir, 'master-stdout.log'); | ||
| const stderrPath = path.join(logDir, 'master-stderr.log'); | ||
| getFrameworkPath(params) { |
| /* istanbul ignore else */ | ||
| if (yield fs.exists(stderrPath)) { | ||
| yield fs.rename(stderrPath, stderrPath + timestamp); | ||
| yield fs.rename(logfile, logfile + timestamp); |
There was a problem hiding this comment.
这里其实如果能重命名为上次启动的时间,而不是本次的时间会更好一点,避免误导。
但好像 fs 拿文件的 create time 不准?
There was a problem hiding this comment.
只是感觉会误导的,一般不都是文件名 + 启动时间 么? 当时想改的,但没找到获取时间的地方。
不过这里面应该也没什么太多有价值的 log。
package.json
Outdated
| "cov": "egg-bin cov", | ||
| "lint": "eslint .", | ||
| "ci": "egg-bin pkgfiles --check && npm run lint && npm run cov", | ||
| "ci": "egg-bin pkgfiles -- --check && npm run lint && npm run cov", |
| const fixturePath = path.join(__dirname, 'fixtures/example'); | ||
| const homePath = homedir(); | ||
| const logDir = path.join(homePath, 'logs/example'); | ||
| const logDir = path.join(homePath, 'logs'); |
There was a problem hiding this comment.
这是 home 目录下的吧,如果同时开多个项目,那边还在跑的时候,这个单测就把人家的日志删了。
test/start.test.js
Outdated
| let result = yield httpclient.request('http://127.0.0.1:7001/env'); | ||
| assert(result.data.toString() === 'pre, true'); | ||
| result = yield httpclient.request('http://127.0.0.1:7001/path'); | ||
| assert(result.data.toString().match(new RegExp(`^${fixturePath}/node_modules/.bin:`))); |
There was a problem hiding this comment.
: 这个改为 path.delimiter 吧,万一后面支持 win
|
+1 |
|
过了 |
|
不用 homedir 的新功能? 那你合了发版本吧 |
|
homedir 已经发布了 |
|
顺便 link 下自定义日志的那个 Issue |
Checklist
npm testpassesAffected core subsystem(s)
Description of change