Changed main a little.
This commit is contained in:
parent
cac5751ede
commit
3ef213ab0d
@ -18,31 +18,29 @@ import (
|
||||
"git.arav.su/Arav/httpr"
|
||||
)
|
||||
|
||||
var version string
|
||||
var (
|
||||
configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
|
||||
noLiquidsoap *bool = flag.Bool("no-liquidsoap", false, "don't run liquidsoap")
|
||||
|
||||
var configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
|
||||
var noLiquidsoap *bool = flag.Bool("no-liquidsoap", false, "don't run liquidsoap")
|
||||
var showVersion *bool = flag.Bool("v", false, "show version")
|
||||
showVersion *bool = flag.Bool("v", false, "show version")
|
||||
)
|
||||
|
||||
var version string
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
log.SetFlags(log.Lshortfile)
|
||||
|
||||
if *showVersion {
|
||||
fmt.Println("dwelling-radio ver.", version, "\nCopyright (c) 2022,2023 Alexander \"Arav\" Andreev <me@arav.su>")
|
||||
return
|
||||
}
|
||||
|
||||
log.SetFlags(log.Lshortfile)
|
||||
|
||||
config, err := configuration.Load(*configPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if typ, addr := config.SplitNetworkAddress(); typ == "unix" {
|
||||
defer os.Remove(addr)
|
||||
}
|
||||
|
||||
if data, err := os.ReadFile(config.MostListenedSongPath); err == nil {
|
||||
if err := radio.LoadMostListenedSong(data); err != nil {
|
||||
log.Fatalln(err)
|
||||
@ -62,11 +60,9 @@ func main() {
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := liquid.Stop(); err != nil {
|
||||
if !errors.Is(err, radio.ErrLiquidsoapNotRunning) {
|
||||
if err := liquid.Stop(); err != nil && !errors.Is(err, radio.ErrLiquidsoapNotRunning) {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@ -93,6 +89,10 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if typ, addr := config.SplitNetworkAddress(); typ == "unix" {
|
||||
defer os.Remove(addr)
|
||||
}
|
||||
|
||||
doneSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGSEGV)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user