improve fault tolerance and OS compat beyond linux
This commit is contained in:
parent
8e4f353be1
commit
75bd36a332
3 changed files with 30 additions and 20 deletions
37
main.go
37
main.go
|
|
@ -40,17 +40,6 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
learningService := learning.New(ctx, learning.ServiceConfig{
|
||||
TitleFilePath: "learning-title.txt",
|
||||
})
|
||||
musicService := music.New(ctx)
|
||||
twitchService, err := twitch.New(ctx, twitch.ServiceOptions{
|
||||
Port: port,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create Twitch service: %v", err)
|
||||
}
|
||||
|
||||
srv := gin.Default()
|
||||
srv.Use(gin.LoggerWithConfig(gin.LoggerConfig{
|
||||
SkipPaths: []string{
|
||||
|
|
@ -59,12 +48,28 @@ func main() {
|
|||
"/learning/public",
|
||||
},
|
||||
}))
|
||||
learningService.BindRoutes(srv.Group("/learning"))
|
||||
musicService.BindRoutes(srv.Group("/music"))
|
||||
twitchService.BindRoutes(srv.Group("/twitch"))
|
||||
|
||||
go musicService.Run(ctx)
|
||||
go twitchService.Run(ctx)
|
||||
learningService := learning.New(ctx, learning.ServiceConfig{
|
||||
TitleFilePath: "learning-title.txt",
|
||||
})
|
||||
learningService.BindRoutes(srv.Group("/learning"))
|
||||
|
||||
musicService, err := music.New(ctx)
|
||||
if err != nil {
|
||||
log.Printf("Failed to create music service: %v", err)
|
||||
} else {
|
||||
musicService.BindRoutes(srv.Group("/music"))
|
||||
go musicService.Run(ctx)
|
||||
}
|
||||
|
||||
twitchService, err := twitch.New(ctx, twitch.ServiceOptions{ Port: port })
|
||||
if err != nil {
|
||||
log.Printf("Failed to create Twitch service: %v", err)
|
||||
} else {
|
||||
twitchService.BindRoutes(srv.Group("/twitch"))
|
||||
go twitchService.Run(ctx)
|
||||
}
|
||||
|
||||
go func() {
|
||||
log.Printf("Now serving at http://%s:%d\n", host, port)
|
||||
failed <- srv.Run(fmt.Sprintf("%s:%d", host, port))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue