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

为什么我点启用一下就给我开了两个nginx,但是点禁用缺只关闭了一个 #31

Closed
hengwei-lhm opened this issue Sep 20, 2018 · 9 comments

Comments

@hengwei-lhm
Copy link

onfigs": [
{
"name": "nginx",
"path": "D:\nginx-1.14.0",
"cmd": "nginx",
"working_directory": "",
"addition_env_path": "",
"use_builtin_console": false,
"is_gui": false,
"enabled": true,
"require_admin": false,
"start_show": false,
"ignore_all": false,
"position": [
0.2,
200
],
"size": [
0.5,
0.5
],
"icon": "",
"alpha": 170,
"topmost": false,
"hotkey": {
"disable_enable": "Shift+Win+D",
"hide_show": "Shift+Win+H",
"restart": "Shift+Win+R",
"elevate": "Shift+Win+A"
},
"not_host_by_commandtrayhost": false,
"not_monitor_by_commandtrayhost": false,
"kill_timeout": 200,
"exclusion_id": 1
}

@rexdf
Copy link
Owner

rexdf commented Sep 20, 2018

首先D:\nginx-1.14.0应该改成D:\\nginx-1.14.0,其次nginx似乎是自己有一个守护进程。

https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer 看下进程树。

我还没在win上跑过nginx,等会我试一下。

@rexdf
Copy link
Owner

rexdf commented Sep 20, 2018

哦 你语法有两个关键错误。

"name": "nginx",
"path": "D:\nginx-1.14.0",
"cmd": "nginx",

应该是

"name": "nginx",
"path": "D:\\nginx-1.14.0",
"cmd": "nginx.exe",

用双斜杠分割路径,以及cmd必须含有.exe四个字符,否则CommandTrayHost就找不到程序了。

解压到另外一个空目录运行一下CommandTrayHost,会自动生成一个config.json,打开它,最上面有几条注释,那个可以看一下。

根据你描述的现象,应该已经解决这个问题就是了。

我粗略看了下 http://nginx.org/en/docs/windows.html

Command comments
nginx -s stop fast shutdown
nginx -s quit graceful shutdown
nginx -s reload changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
nginx -s reopen re-opening log files

晚些时候我研究下

@hengwei-lhm
Copy link
Author

@rexdf 非常感谢

@hengwei-lhm
Copy link
Author

@rexdf
我是 D:\\nginx-1.14.0
github评论的时候给我改成了 D:\nginx-1.14.0
"cmd": "nginx"
好像也可以运行
有什么办法 能设置重启命令么

@rexdf
Copy link
Owner

rexdf commented Sep 20, 2018

nginx自带守护,它会自动再次以子进程的方式再启动一个。你可以不用CommandTrayHost,直接用运行试一下,如下图所示。杀掉父进程,子进程并不会自动被杀掉。

image

启动那个父进程是用来守护worker进程的。worker进程应该就是用来处理外部网络请求的。

这样看似乎 重启(nginx -s reload)、关闭(nginx -s quit)都需要特别操作。而CommandTrayHost目前只是简单地重启和杀父进程,子进程会残留。

虽然写两三个批处理,一个重启,一个关闭、一个启动,可以做成三个菜单,还可以绑定快捷键。但是这失去了CommandTrayHost主要的功能。

所以目前还是推荐用批处理来做这事了。 或者等我空下来读一下nginx源码,看有没有有啥比较优雅的方式,

@rexdf
Copy link
Owner

rexdf commented Sep 20, 2018

嗯 我又看了下,其实大部分功能好像都是期望的(虽然显示功能没有显示命令行界面,因为本来就没有),只是重启与关闭的时候 残留了那个子进程。 也许只要把子进程一同杀掉就好了?

@rexdf
Copy link
Owner

rexdf commented Sep 20, 2018

如果带命令行参数一定要加.exe,它会找这四个作为分隔符,这个是可能刚好能够运行(运行命令前,有一个逻辑是看这个exe文件在不在磁盘上,不存在就放弃执行了)。

@rexdf
Copy link
Owner

rexdf commented Sep 20, 2018

试下最新版,现在不会有进程残留了。加了个参数kill_process_tree

@hengwei-lhm
Copy link
Author

@rexdf 非常感谢 可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants