Removed log-stdout flag. Ditched self-made logging.
This commit is contained in:
parent
8db8086c58
commit
0bb2cf9a08
@ -18,7 +18,6 @@ import (
|
||||
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")
|
||||
|
||||
@ -35,8 +34,6 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if *logToStdout {
|
||||
config.Log.ToStdout = true
|
||||
}
|
||||
|
||||
defer func() {
|
||||
@ -45,15 +42,10 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
logErr, err := logging.NewLogger(config.Log.Error, config.Log.ToStdout)
|
||||
if err != nil {
|
||||
log.Fatalln("error logger:", err)
|
||||
}
|
||||
defer logErr.Close()
|
||||
|
||||
playlistWatcher := radio.NewPlaylistLogWatcher()
|
||||
if err := playlistWatcher.Watch(config.Icecast.Playlist, config.ListLastNSongs); err != nil {
|
||||
logErr.Fatalln(err)
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer playlistWatcher.Close()
|
||||
|
||||
@ -69,40 +61,28 @@ func main() {
|
||||
if !*noLiquidsoap {
|
||||
liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath)
|
||||
if err != nil {
|
||||
logErr.Fatalln("liquidsoap:", err)
|
||||
log.Fatalln("liquidsoap:", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := liquid.Stop(); err != nil {
|
||||
if !errors.Is(err, radio.ErrLiquidsoapNotRunning) {
|
||||
logErr.Println(err)
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := srv.Start(config.SplitNetworkAddress()); err != nil {
|
||||
logErr.Fatalln(err)
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
logReload := make(chan os.Signal, 1)
|
||||
signal.Notify(logReload, syscall.SIGHUP)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-logReload:
|
||||
logErr.Reopen(config.Log.Error)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
doneSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
<-doneSignal
|
||||
|
||||
if err := srv.Stop(); err != nil {
|
||||
logErr.Fatalln(err)
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user