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

fix: should stop app when baseDir is symlink #12

Merged
merged 1 commit into from
Nov 14, 2017
Merged

Conversation

popomore
Copy link
Member

@popomore popomore commented Nov 14, 2017

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

@@ -37,7 +37,7 @@ class StopCommand extends Command {
// node /Users/tz/Workspaces/eggjs/egg-scripts/lib/start-cluster {"title":"egg-server","workers":4,"port":7001,"baseDir":"/Users/tz/Workspaces/eggjs/test/showcase","framework":"/Users/tz/Workspaces/eggjs/test/showcase/node_modules/egg"}
let processList = yield this.helper.findNodeProcess(item => {
const cmd = item.cmd;
return cmd.includes(this.serverBin) && cmd.includes(`"baseDir":"${baseDir}"`);
return cmd.includes('start-cluster');
Copy link
Member

Choose a reason for hiding this comment

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

这里之前也是纠结要不要严谨一点,否则 window 的用 find-process 就很好搞了。

这里不判断目录的话,会 kill 掉其他 egg 应用吧,有些场景是一个机器多个 egg,没 docker 隔离的。

Copy link
Member Author

@popomore popomore Nov 14, 2017

Choose a reason for hiding this comment

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

隔离的到时可以加个唯一 id 做标识,我们应该不推崇这种方式,支持部署脚本支持一下。

Copy link
Member

Choose a reason for hiding this comment

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

至少判断下 baseDir 的 basename?

Copy link
Member Author

Choose a reason for hiding this comment

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

如果真是软连接,basename 也不一定一样

Choose a reason for hiding this comment

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

追加个port值是否更精确呢

Choose a reason for hiding this comment

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

你指的是worker的监听端口会随着重启而不断变化么? 不过master的端口是固定的吧

Copy link
Member

Choose a reason for hiding this comment

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

master 不提供 http 服务,无端口。

Choose a reason for hiding this comment

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

那监听0.0.0.0:7001端口的node进程(并且包含多个子进程)不是master进程?

Choose a reason for hiding this comment

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

node 9.2 支持 process.ppid
nodejs/node#16839

Copy link
Member

@atian25 atian25 Nov 15, 2017

Choose a reason for hiding this comment

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

master - agent - workerS(7001)

https://eggjs.org/zh-cn/core/cluster-and-ipc.html

@popomore
Copy link
Member Author

后面可以用 title 做标识,如果开发者指定了才设置,stop 的时候如果指定了则根据这个过滤

@popomore popomore merged commit 7324d99 into master Nov 14, 2017
@popomore popomore deleted the fix-stop-basedir branch November 14, 2017 06:26
@popomore
Copy link
Member Author

@atian25
Copy link
Member

atian25 commented Nov 14, 2017

也就是:

  • 默认会 kill 带有 start-cluster 的 process,存在的风险是 kill 掉了同机的其他 process 甚至其他非 egg
    应用
  • 如果用户单机部署多个实例的话,要求必须启动关闭时带有 title 标识
  • 这样的话,win 兼容性就绕过了,可以支持了。

popomore added a commit that referenced this pull request Nov 14, 2017
popomore added a commit that referenced this pull request Nov 14, 2017
@popomore
Copy link
Member Author

@atian25 要不要和 #11 的一起看看

@atian25
Copy link
Member

atian25 commented Nov 14, 2017

嗯,主要是要确定下,我们的寻找 pid 逻辑是怎么样才合理,我之前的做法是太严格了导致 win 那边反斜杠很难处理。

@atian25
Copy link
Member

atian25 commented Nov 15, 2017 via email

@waitingsong
Copy link

你上面说“master 不提供 http 服务,无端口。”
那么请问监听7002主端口的6872进程是master还是agent进程?

@atian25
Copy link
Member

atian25 commented Nov 15, 2017 via email

@popomore
Copy link
Member Author

发布系统的应用代码会放在 一个发布 id 目录下,然后链接到固定目录,发布会切换软链接

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.

3 participants