Skip to content

feat: support win32 #11

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

Closed
wants to merge 12 commits into from
Closed

Conversation

waitingsong
Copy link

@waitingsong waitingsong commented Nov 7, 2017

it should stop with --port if start cluster with custom port number

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

it should stop with --port if start cluster with custom port number
@codecov-io
Copy link

codecov-io commented Nov 7, 2017

Codecov Report

Merging #11 into master will decrease coverage by 15.22%.
The diff coverage is 28.2%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #11       +/-   ##
===========================================
- Coverage     100%   84.77%   -15.23%     
===========================================
  Files           6        6               
  Lines         169      197       +28     
===========================================
- Hits          169      167        -2     
- Misses          0       30       +30
Impacted Files Coverage Δ
lib/cmd/stop.js 93.54% <100%> (-6.46%) ⬇️
lib/helper.js 48.78% <16%> (-51.22%) ⬇️
lib/cmd/start.js 93.39% <46.15%> (-6.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0016e28...9199d58. Read the comment docs.

@fengmk2
Copy link
Member

fengmk2 commented Nov 7, 2017

@atian25 add appveyor tests

@atian25
Copy link
Member

atian25 commented Nov 7, 2017

but egg-scripts start is not support windows yet, so appveyor will break, should we still open it?

@waitingsong
Copy link
Author

I run test local all passed under win7. not support ?

@atian25
Copy link
Member

atian25 commented Nov 7, 2017

https://github.com/eggjs/egg-scripts/blob/master/lib/cmd/start.js#L180-L196

tails is support at win? maybe you had install some tool such as git bin (with an options to install bash tools)

@waitingsong
Copy link
Author

waitingsong commented Nov 7, 2017

oh, git installed .maybe can be fixed for win32

@waitingsong
Copy link
Author

waitingsong commented Nov 7, 2017

 stdout = stdout.split(/\n+/g).splice(0, 100);
 +            this.logger.error(stdout);
 +            this.logger.error('Start failed, see %s', stderr);

Whether need convert stdout to string by stdout.join('\n') ?

lib/cmd/start.js Outdated
break;
} else {
const str = fs.readFileSync(stderr, 'utf-8');
let stdout = str ? str.slice(0, 50000).replace(/\r/g, '\n') : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simply print all on windows

Copy link
Author

@waitingsong waitingsong Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是参考源代码 tail 前100行,故以一行500字节*100行计算来截取 50000字节。

const { argv } = context;
const port = argv.port || (process.env && process.env.PORT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there other way to stop without port

Copy link
Author

@waitingsong waitingsong Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有其他方法。但相当复杂
1、修改egg-cluster, 在启动 worker 进程时,更新窗口的 title
2、在关闭服务时借助node-ffi 找到任何一个匹配 title 的 worker 窗口获取其pid
3、借助node-ffi 调用 ntdll.NtQueryInformationProcess() 方法,根据pid找到父级pid(即master进程),然后kill。

我计划实现(1, 2),并且可根据参数隐藏worker的窗口。
因为master进程没有窗口,也就无法设置其窗口 title,所以只有在 worker 上面设置了。 否则就可以跳过(3)直接找到 master 进程窗口然后 kill 之。

(3)这个 NtQueryInformationProcess 需要的 参数结构Struct极其复杂,目前搞不定。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we can store port when app starts, so it’s unnecessary to give the port argument.

Copy link
Author

@waitingsong waitingsong Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能记录所有进程 pid 那当然就方便了

@atian25
Copy link
Member

atian25 commented Nov 7, 2017 via email

@atian25
Copy link
Member

atian25 commented Nov 8, 2017

https://ci.appveyor.com/project/eggjs/egg-scripts

had enabled, need an empty commit to trigger it.

btw, the cov is low.

@waitingsong
Copy link
Author

waitingsong commented Nov 8, 2017

commit one, but seems not triggered. only master branch?

@atian25
Copy link
Member

atian25 commented Nov 8, 2017

try again and see, just delete and recreate it.

lib/cmd/start.js Outdated
isSuccess = false;
break;
} else {
const str = fs.readFileSync(stderr, 'utf-8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use yield fs.readFile

@waitingsong waitingsong closed this Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants