2017-07-31 18:11:58 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12"
|
2017-07-31 18:11:58 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := iris.New()
|
|
|
|
|
2018-10-21 18:20:05 +02:00
|
|
|
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")
|
|
|
|
})
|
|
|
|
|
2020-03-05 21:41:27 +01:00
|
|
|
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
2018-10-21 18:20:05 +02:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2017-07-31 18:11:58 +02:00
|
|
|
}
|