-
Notifications
You must be signed in to change notification settings - Fork 37
feat: stop command support windows #22
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
Changes from all commits
bfa9c9c
ec2fb5c
0f89f2d
9d9c9ce
908efbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
'use strict'; | ||
|
||
const runScript = require('runscript'); | ||
const REGEX = /^\s*(\d+)\s+(.*)/; | ||
const isWin = process.platform === 'win32'; | ||
const REGEX = isWin ? /^(.*)\s+(\d+)\s*$/ : /^\s*(\d+)\s+(.*)/; | ||
|
||
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 commentThe 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 commentThe 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 commentThe 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 commentThe 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.
so I give up. @BaffinLee maybe you could help us try again ? and you need to config package.json for my commit: https://github.com/eggjs/egg-scripts/pull/1/commits There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. @atian25 It seems some people have the same issue about what about I am going to test it on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worker for most of the window user is better than nothing~ |
||
'ps -eo "pid,command"'; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. why not just change There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. In my test, So I just put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still confusing, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something wrong with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird:
refer to how-to-prevent-ps-from-truncating-the-process-name, I think I should rollback :) ? or set column width like: I'd like to rollback, any idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (!filterFn || filterFn(item)) { | ||
arr.push(item); | ||
} | ||
|
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.
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.
https://ci.appveyor.com/project/eggjs/egg-scripts
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