1
0

Added a --no-liquidsoap flag to not start a liquidsoap.

This commit is contained in:
Alexander Andreev 2022-08-30 00:14:39 +04:00
parent 29cc7afb77
commit e3112cb4d2
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -20,6 +20,7 @@ var version string
var configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
var logToStdout *bool = flag.Bool("log-stdout", false, "write logs to stdout")
var noLiquidsoap *bool = flag.Bool("no-liquidsoap", false, "don't run liquidsoap")
var showVersion *bool = flag.Bool("v", false, "show version")
func main() {
@ -65,10 +66,20 @@ 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 {
liquid.Stop()
logErr.Fatalln("liquidsoap:", err)
if !*noLiquidsoap {
liquid, err := liquidsoap.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath)
if err != nil {
liquid.Stop()
logErr.Fatalln("liquidsoap:", err)
}
defer func() {
if err := liquid.Stop(); err != nil {
if !errors.Is(err, liquidsoap.ErrNotRunning) {
logErr.Println("liquidsoap:", err)
}
}
}()
}
if err := srv.Start(config.SplitNetworkAddress()); err != nil {
@ -92,12 +103,6 @@ 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)
}