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