WinSW 配置 nginx 服务#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| <service>
<id>nginx service</id>
<name>Nginx</name>
<description>Nginx服务.</description>
<!-- 环境变量 -->
<env name="NGINX_COMIC" value="%BASE%" />
<executable>%base%\nginx.exe</executable>
<workingdirectory>%BASE%</workingdirectory>
<arguments>-p %BASE%</arguments>
<!-- 日志配置 -->
<logpath>%BASE%\logs</logpath>
<log mode="roll-by-size">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>8</keepFiles>
</log>
<!-- 启动模式 -->
<startmode>Automatic</startmode>
<delayedAutoStart>true</delayedAutoStart>
<!-- 停止配置 - 使用nginx -s quit实现优雅停止 -->
<stopexecutable>%BASE%\nginx.exe</stopexecutable>
<stoparguments>-s quit</stoparguments>
<stoptimeout>15sec</stoptimeout>
<!-- 重启配置 -->
<restartexecutable>%BASE%\nginx.exe</restartexecutable>
<restartarguments>-s reload</restartarguments>
<!-- 失败恢复策略 -->
<onfailure action="restart" delay="10 sec"/>
<onfailure action="restart" delay="20 sec"/>
<onfailure action="none" delay="30 sec"/>
</service>
|
通过以上配置,Nginx 将作为标准的 Windows 服务运行,支持正常的启动、停止和重启操作,并且能够自动恢复故障。