-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
48 lines (37 loc) · 905 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
47
48
package main
import (
"os"
"os/signal"
"syscall"
"github.com/rs/zerolog/log"
"treehole_next/bootstrap"
)
// @title Open Tree Hole
// @version 2.1.0
// @description An Anonymous BBS \n Note: PUT methods are used to PARTLY update, and we don't use PATCH method.
// @contact.name Maintainer Ke Chen
// @contact.email dev@danta.tech
// @license.name Apache 2.0
// @license.url https://www.apache.org/licenses/LICENSE-2.0.html
// @host
// @BasePath /api
func main() {
app, cancel := bootstrap.Init()
go func() {
err := app.Listen("0.0.0.0:8000")
if err != nil {
log.Fatal().Err(err).Msg("app listen failed")
}
}()
interrupt := make(chan os.Signal, 1)
// wait for CTRL-C interrupt
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
<-interrupt
// close app
err := app.Shutdown()
if err != nil {
log.Err(err).Msg("error shutdown app")
}
// stop tasks
cancel()
}