-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
main.go
28 lines (22 loc) · 762 Bytes
/
main.go
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
package main
import (
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
app.ConfigureHost(func(host *iris.Supervisor) { // <- HERE: IMPORTANT
// You can control the flow or defer something using some of the host's methods:
// host.RegisterOnError
// host.RegisterOnServe
host.RegisterOnShutdown(func() {
app.Logger().Infof("Application shutdown on signal")
})
})
app.Get("/", func(ctx iris.Context) {
ctx.HTML("<h1>Hello</h1>\n")
})
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
/* There are more easy ways to notify for global shutdown using the `iris.RegisterOnInterrupt` for default signal interrupt events.
You can even go it even further by looking at the: "graceful-shutdown" example.
*/
}