Skip to content

Commit 632aafb

Browse files
committed
添加shutdown和startup指令
1 parent 9028470 commit 632aafb

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# shutdown
2+
shutdown executes a command when the server exits. This is useful for performing cleanup or stopping a background process like php-fpm. (Also see startup.)
3+
4+
Each command that is executed at shutdown is blocking. The output and error of the command go to stdout and stderr, respectively. There is no stdin.
5+
6+
Note that shutdown commands will not execute if Caddy is force-terminated, for example, by using a "Force Quit" feature provided by your operating system. However, a typical SIGINT (Ctrl+C) will allow the shutdown commands to execute.
7+
8+
Even if this directive is shared by more than one host, the command will only execute once per appearance in the Caddyfile.
9+
10+
## 语法
11+
shutdown command
12+
13+
command is the command to execute; it may be followed by arguments
14+
15+
## 例子
16+
Stop php-fpm when the server quits:
17+
18+
shutdown /etc/init.d/php-fpm stop

docs-cn/HTTP Directives/startup.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# startup
2+
startup executes a command when the server begins. This is useful for preparing to serve a site by running a script or starting a background process like php-fpm. (Also see shutdown.)
3+
启动在服务器开始时执行命令。 这对于通过运行脚本或启动像php-fpm这样的后台进程来准备服务站点是非常有用的。 (另请参见关机。)
4+
5+
Each command that is executed at startup is blocking, unless you suffix the command with a space and &, which will cause the command to be run in the background. The output and error of the command go to stdout and stderr, respectively. There is no stdin.
6+
在启动时执行的每个命令都是阻塞的,除非后缀有空格和&,这将导致命令在后台运行。 命令的输出和错误分别转到stdout和stderr。 没有标准
7+
8+
A command will only be executed once for each time it appears in the Caddyfile.
9+
每次只能在Caddyfile中执行一次命令。
10+
11+
## 语法
12+
```
13+
startup command
14+
```
15+
16+
`command` 是一个可执行的命令,它的后面可以带有参数
17+
18+
## 例子
19+
在服务开始监听之前启动php-fpm:
20+
21+
```
22+
startup /etc/init.d/php-fpm start
23+
```
24+
25+
在Windows系统上,当命令的路径包含空格时,你可能需要使用引号:
26+
27+
```
28+
startup "\"C:\Program Files\PHP\v7.0\php-cgi.exe\" -b 127.0.0.1:9123" &
29+
```

0 commit comments

Comments
 (0)