mirror of
https://github.com/labstack/echo.git
synced 2025-06-02 23:27:34 +02:00
[doc] adding graceful documentation and example. (#688)
* [doc] adding graceful documentation and example. * adding myself to the maintainers list and minor comment formatting change
This commit is contained in:
parent
2fbaf3a363
commit
ffdb76efc7
22
recipe/graceful-shutdown/server.go
Normal file
22
recipe/graceful-shutdown/server.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/labstack/echo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
e := echo.New()
|
||||||
|
|
||||||
|
// Setting up the termination timeout to 30 seconds.
|
||||||
|
e.ShutdownTimeout = 30 * time.Second
|
||||||
|
|
||||||
|
e.GET("/", func(ctx echo.Context) error {
|
||||||
|
return ctx.String(200, "OK")
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := e.Start(":1323"); err != nil {
|
||||||
|
e.Logger.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
@ -9,23 +9,21 @@ description = "Graceful shutdown recipe / example for Echo"
|
|||||||
|
|
||||||
## Graceful Shutdown Recipe
|
## Graceful Shutdown Recipe
|
||||||
|
|
||||||
### Using [grace](https://github.com/facebookgo/grace)
|
Echo now ships with graceful server termination inside it, to accomplish it Echo uses `github.com/tylerb/graceful` library.
|
||||||
|
|
||||||
|
By Default echo uses 15 seconds as shutdown timeout, giving 15 secs to open connections at the time the server starts to shut-down.
|
||||||
|
|
||||||
|
In order to change this default 15 seconds you could change the `ShutdownTimeout` property of your Echo instance as needed by doing something like:
|
||||||
|
|
||||||
`server.go`
|
`server.go`
|
||||||
|
|
||||||
{{< embed "graceful-shutdown/grace/server.go" >}}
|
{{< embed "graceful-shutdown/server.go" >}}
|
||||||
|
|
||||||
### Using [graceful](https://github.com/tylerb/graceful)
|
|
||||||
|
|
||||||
`server.go`
|
|
||||||
|
|
||||||
{{< embed "graceful-shutdown/graceful/server.go" >}}
|
|
||||||
|
|
||||||
### Maintainers
|
### Maintainers
|
||||||
|
|
||||||
- [mertenvg](https://github.com/mertenvg)
|
- [mertenvg](https://github.com/mertenvg)
|
||||||
|
- [apaganobeleno](https://github.com/apaganobeleno)
|
||||||
|
|
||||||
### Source Code
|
### Source Code
|
||||||
|
|
||||||
- [graceful]({{< source "graceful-shutdown/graceful" >}})
|
- [graceful]({{< source "graceful-shutdown/graceful" >}})
|
||||||
- [grace]({{< source "graceful-shutdown/grace" >}})
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user