1
0

Launch and stop liquidsoap in a main file.

This commit is contained in:
Alexander Andreev 2022-08-29 07:20:58 +04:00
parent 0da8077ab7
commit 23f246857e
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -4,8 +4,10 @@ import (
"dwelling-radio/internal/configuration"
"dwelling-radio/internal/handlers"
"dwelling-radio/internal/radio"
"dwelling-radio/internal/radio/liquidsoap"
"dwelling-radio/pkg/logging"
"dwelling-radio/pkg/server"
"errors"
"flag"
"fmt"
"log"
@ -63,6 +65,11 @@ func main() {
srv.GET("/lastsong", hand.LastSong)
srv.GET("/playlist", hand.Playlist)
liquid, err := liquidsoap.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath)
if err != nil {
logErr.Fatalln("liquidsoap:", err)
}
if err := srv.Start(config.SplitNetworkAddress()); err != nil {
logErr.Fatalln(err)
}
@ -84,6 +91,12 @@ func main() {
<-doneSignal
if err := liquid.Stop(); err != nil {
if !errors.Is(err, liquidsoap.ErrNotRunning) {
logErr.Println("liquidsoap:", err)
}
}
if err := srv.Stop(); err != nil {
logErr.Fatalln(err)
}