Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ h.Engine.OnShutdown = append(h.Engine.OnShutdown, shutDownFunc)

`waitSignal` is default implementation for signal waiter,which is executed as follows:

Version **< v0.9.6**

- SIGTERM triggers immediately close.
- SIGHUP|SIGINT triggers graceful shutdown.

Version **>= v0.9.6**

- SIGTERM|SIGHUP|SIGINT triggers graceful shutdown.

If Default one is not met the requirement, `SetCustomSignalWaiter` set this function to customize.

```go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Hertz 支持优雅退出,优雅退出过程如下:
4. 关闭网络库的信号监听
5. 对处于关闭过程中的请求回包统一带上 `Connection:Close` header
6. `Select` 等待业务协程退出:
1. 对于 netpoll 网络库,开启默认 1s(netpoll 中设置,暂时不可更改)的 `ticker`,定时查看 `active conn`(业务 handle 退出且连接不处于阻塞读状态)是否为 0;对于 go net 网络库,则关闭监听,不对连接做处理。
2. 等待超时时间为 `ExitWaitTime` 的 context 触发,默认 5s
1. 对于 netpoll 网络库,开启默认 1s(netpoll 中设置,暂时不可更改)的 `ticker`,定时查看 `active conn`(业务 handle 退出且连接不处于阻塞读状态)是否为 0;对于 go net 网络库,则关闭监听,不对连接做处理。
2. 等待超时时间为 `ExitWaitTime` 的 context 触发,默认 5s

如需修改等待超时时间,可通过 `server.WithExitWaitTime()` 进行配置。

Expand All @@ -27,9 +27,15 @@ h.Engine.OnShutdown = append(h.Engine.OnShutdown, shutDownFunc)

Hertz 使用 `waitSignal` 函数作为信号处理的默认实现方式,处理如下:

版本 **< v0.9.6**

- 当接收到 `SIGTERM` 系统信号时触发立即退出。
- 当接收到 `SIGHUP|SIGINT` 系统信号时触发优雅退出。

版本 **>= v0.9.6**

- 当接收到 `SIGTERM|SIGHUP|SIGINT` 系统信号时触发优雅退出。

当信号处理的默认实现方式无法满足需求时,可通过 `SetCustomSignalWaiter` 来自定义信号处理方式。

```go
Expand Down