OpenMediaCenter/apiGo/main.go
lukas 334c54be4a fix linter warnings
one method to add handlers
2021-09-21 10:45:52 +02:00

50 lines
1020 B
Go

package main
import (
"fmt"
"openmediacenter/apiGo/api"
api2 "openmediacenter/apiGo/api/api"
"openmediacenter/apiGo/config"
"openmediacenter/apiGo/database"
"openmediacenter/apiGo/static"
"openmediacenter/apiGo/videoparser"
"os"
"os/signal"
)
func main() {
fmt.Println("init OpenMediaCenter server")
const port uint16 = 8081
config.Init()
// todo some verbosity logger or sth
fmt.Printf("Use verbose output: %t\n", config.GetConfig().General.VerboseLogging)
fmt.Printf("Videopath prefix: %s\n", config.GetConfig().General.ReindexPrefix)
database.InitDB()
defer database.Close()
api.AddHandlers()
videoparser.SetupSettingsWebsocket()
// add the static files
static.ServeStaticFiles()
// init api
errc := make(chan error, 1)
go func() {
errc <- api2.ServerInit(port)
}()
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt)
select {
case err := <-errc:
fmt.Printf("failed to serve: %v\n", err)
case sig := <-sigs:
fmt.Printf("terminating server: %v\n", sig)
}
}