-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
46 lines (36 loc) · 880 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
_ "github.com/opentreehole/go-common" // init common, zerolog setting
"github.com/rs/zerolog/log"
"notification/app"
"os"
"os/signal"
"syscall"
)
// @title Notification Center
// @version 2.0.0
// @description This is a notification microservice.
// @contact.name Maintainer OpenTreeHole
// @contact.email dev@fduhole.com
// @license.name Apache 2.0
// @license.url https://www.apache.org/licenses/LICENSE-2.0.html
// @host
// @BasePath /api
func main() {
a := app.Create()
go func() {
err := a.Listen("0.0.0.0:8000")
if err != nil {
log.Fatal().Err(err).Msg("failed to listen")
}
}()
interrupt := make(chan os.Signal, 1)
// wait for CTRL-C interrupt
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
<-interrupt
// close app
err := a.Shutdown()
if err != nil {
log.Warn().Err(err).Msg("failed to shutdown")
}
}