-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: stop command support windows #22
Conversation
Codecov Report
@@ Coverage Diff @@
## master #22 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 6 6
Lines 187 190 +3
=====================================
+ Hits 187 190 +3
Continue to review full report at Codecov.
|
|
||
exports.findNodeProcess = function* (filterFn) { | ||
const command = 'ps -eo "pid,command"'; | ||
const command = isWin ? | ||
'wmic Path win32_process Where "Name = \'node.exe\'" Get CommandLine,ProcessId' : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not familiar with Windows, is wmic a buildin command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, from Microsoft offical docs, but I am not sure about Windows XP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had try https://www.npmjs.com/package/find-process long long ago.
but got some trouble:
XML invalid
at some win10.- backslash convert confuse me at
appveyor
so I give up.
@BaffinLee maybe you could help us try again ?
and you need to config package.json for egg-ci
to gen appveyor.yml, so this feature could be test.
my commit: https://github.com/eggjs/egg-scripts/pull/1/commits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atian25 It seems some people have the same issue about Invalid XML content
. I can't figure out why, I have tested the script on 3 windows pc, works fine.
what about wmic Path win32_process Where "Name = 'node.exe'" Get CommandLine,ProcessId
, output the same error ?
I am going to test it on appveyor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worker for most of the window user is better than nothing~
const stdio = yield runScript(command, { stdio: 'pipe' }); | ||
const processList = stdio.stdout.toString().split('\n') | ||
.reduce((arr, line) => { | ||
if (!!line && !line.includes('/bin/sh') && line.includes('node')) { | ||
const m = line.match(REGEX); | ||
/* istanbul ignore else */ | ||
if (m) { | ||
const item = { pid: m[1], cmd: m[2] }; | ||
const item = isWin ? { pid: m[2], cmd: m[1] } : { pid: m[1], cmd: m[2] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just change Get CommandLine,ProcessId
to Get ProcessId,CommandLine
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 after fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my test, ProcessId
always show behind CommandLine
, despite how you run the command.
So I just put ProcessId
behind CommandLine
, more clear, less confuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about change the ps
of linux to make they the same order ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still confusing, Get CommandLine,ProcessId
and Get ProcessId,CommandLine
actually output the same thing, maybe I should add a comment in the code ? Got better idea? @atian25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something wrong with the REGEXP
in my final commit, I will switch to linux to test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird:
ps -eo pid,command
works fine
fake@ubuntu$ ps -eo pid,command
PID COMMAND
1 /init ro
24 ssh-agent
205 /init ro
206 -bash
2956 /init ro
2957 -bash
5274 npm
5284 sh -c npm run lint -- --fix && npm run pkgfiles && npm run test-local
5325 npm
5335 sh -c egg-bin test
5336 node /mnt/c/Users/fake/code/egg-scripts/node_modules/.bin/egg-bin test
5342 /usr/local/lib/nodejs/node/bin/node /mnt/c/Users/fake/code/egg-scripts/node_modules/egg-bin/node_modules/mocha/bin/_mocha --require=/mnt/c/Users/fake/code/egg-scripts/node_modules/egg-bin/lib/mocha-clean.js --require=/mnt/c/U...
5595 node /mnt/c/Users/fake/code/egg-scripts/lib/start-cluster {"framework":"/mnt/c/Users/fake/code/egg-scripts/test/fixtures/example/node_modules/yadan","workers":2,"title":"egg-server-example","baseDir":"/mnt/c/Users/fake/cod...
5680 /usr/local/lib/nodejs/node/bin/node /mnt/c/Users/fake/code/egg-scripts/bin/egg-scripts.js start --workers=2 --title=egg-test /mnt/c/Users/fake/code/egg-scripts/test/fixtures/example
5690 node /mnt/c/Users/fake/code/egg-scripts/lib/start-cluster {"workers":2,"title":"egg-test","framework":"/mnt/c/Users/fake/code/egg-scripts/test/fixtures/example/node_modules/custom-framework","baseDir":"/mnt/c/Users/fake/co...
5696 /usr/local/lib/nodejs/node/bin/node /mnt/c/Users/fake/code/egg-scripts/node_modules/egg-cluster/lib/agent_worker.js {"framework":"/mnt/c/Users/fake/code/egg-scripts/test/fixtures/example/node_modules/custom-framework","baseDi...
5706 /usr/local/lib/nodejs/node/bin/node /mnt/c/Users/fake/code/egg-scripts/node_modules/egg-cluster/lib/app_worker.js {"framework":"/mnt/c/Users/fake/code/egg-scripts/test/fixtures/example/node_modules/custom-framework","baseDir"...
5707 /usr/local/lib/nodejs/node/bin/node /mnt/c/Users/fake/code/egg-scripts/node_modules/egg-cluster/lib/app_worker.js {"framework":"/mnt/c/Users/fake/code/egg-scripts/test/fixtures/example/node_modules/custom-framework","baseDir"...
ps -eo command,pid
faild: command
was truncated
fake@ubuntu$ ps -eo command,pid
COMMAND PID
/init ro 1
ssh-agent 24
/init ro 205
-bash 206
/init ro 2956
-bash 2957
npm 5274
sh -c npm run lint -- --fix 5284
npm 5325
sh -c egg-bin test 5335
node /mnt/c/Users/fake/c 5336
/usr/local/lib/nodejs/node/ 5342
node /mnt/c/Users/fake/c 5595
/usr/local/lib/nodejs/node/ 5680
node /mnt/c/Users/fake/c 5690
/usr/local/lib/nodejs/node/ 5696
/usr/local/lib/nodejs/node/ 5706
/usr/local/lib/nodejs/node/ 5707
ps -eo command,pid 5741
refer to how-to-prevent-ps-from-truncating-the-process-name, I think I should rollback :) ? or set column width like: ps -eo command:1000,pid
?
I'd like to rollback, any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, just rollback to last review, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should change README.md https://github.com/eggjs/egg-scripts/blob/master/README.md#egg-scripts too. |
@fengmk2 done. |
@@ -2,7 +2,7 @@ | |||
|
|||
deploy tool for egg project. | |||
|
|||
**Note: Windows is not supported** | |||
**Note: Windows is partially supported, see [#22](https://github.com/eggjs/egg-scripts/pull/22)** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- egg guide docs of deploy is also need to updated.
- could raise anthoer PR to support
start
for win (if nottail
instead, just ignore the checker at win)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR for egg's docs, #2788
|
有个现象, vscode 调试 egg 中,wmic 持续出现在系统任务列表中。大概3秒执行一次,每次0.3秒左右。
单独运行 |
是吧,调试应该没用到 |
Checklist
npm test
passesAffected core subsystem(s)
stop
command supports windows now.Description of change
Adjust find process command and filter logic to support windows, done simple than other pr.
Tested on Windows 7 and Windows 10, works fine.
By the way, the
npm run test
wouldn't pass even if I don't change anything, which I didn't dig in.