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

有点疑问 #4

Open
lesteryou opened this issue May 4, 2019 · 1 comment
Open

有点疑问 #4

lesteryou opened this issue May 4, 2019 · 1 comment

Comments

@lesteryou
Copy link

  1. 刚才阅读了代码,好像没发现可以 作为服务,或者 daemon 守护进程使用。Naruto\Daemon 好像是用来管理进程。这样,如果关闭终端,脚本不是会终止吗?
  2. 多进程开发,如果涉及守护进程 首先运行脚本,当前脚本fock一个进程作为master,然后脚本终止。master进程再fork出work进程,work进程负责处理业务部分。但是你这好像是 脚本进程作为master进程,然后fork出work进程,而且work进程的存活与否是通过shell命令来统计出来的。这样做的话,如果work进程变成僵尸进程怎么办。正常情况,work进程作为master进程,其异常终止时都会告知master,然后可以根据情况是否master再fork新的work进程。
  3. 程序 启动之后,会一直处于前台。stop和reload命名只能重新开启终端来操作,但是 reload好像会重新加载程序,但是之前因为没有停止,会继续运行,导致,会出现双倍的进程。

PS:刚接触多进程开发,可能表达的有错误的地方,请帮忙指出,谢谢。

@TIGERB
Copy link
Owner

TIGERB commented May 5, 2019

  1. 使用 nobup & 运行脚本;或者screen or tmux;

  2. Manager.php 428行 $res = pcntl_waitpid($v->pid, $status, WNOHANG);的作用就是防止worker进程变成僵尸进程;worker进程异常退出这里是知道的。

3.可能是环境的问题,目前mac&debian下正常。

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

No branches or pull requests

2 participants