Skip to content

Commit

Permalink
readme: add graceful shutdown multiple app
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed May 29, 2018
1 parent c33fe3b commit 2f218d3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ templates:
- _layout.tmpl
about.tmpl: [about.tmpl, _layout.tmpl]
server:
addr: :8080
readTimeout: 10s
readHeaderTimeout: 5s
writeTimeout: 5s
Expand All @@ -280,6 +281,7 @@ routes:
```yaml
// server.yaml
server:
addr: :8080
readTimeout: 10s
readHeaderTimeout: 5s
writeTimeout: 5s
Expand Down Expand Up @@ -313,6 +315,29 @@ app := hime.New().
app.Template().ParseConfigFile("template.web.yaml")
```

## Graceful Shutdown Multiple Apps

Hime can handle graceful shutdown for multiple Apps.

```go
app1 := hime.New().ParseConfigFile("app1.yaml")
app2 := hime.New().ParseConfigFile("app2.yaml")

probe := probehandler.New() // github.com/acoshift/probehandler
health := http.NewServeMux()
health.Handle("/readiness", probe)
health.Handle("/liveness", probehandler.Success())
go http.ListenAndServe(":18080", health)

err := hime.Merge(app1, app2).
GracefulShutdown().
Notify(probe.Fail).
ListenAndServe()
if err != nil {
log.Fatal(err)
}
```

## Useful handlers and middlewares

- [acoshift/middleware](https://github.com/acoshift/middleware)
Expand Down

0 comments on commit 2f218d3

Please sign in to comment.