1
0

Write listeners statistics for a current song in case of an interrupting signal.

This commit is contained in:
Alexander Andreev 2024-05-11 04:22:06 +04:00
parent d94c029fda
commit 454df3bb74
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34

View File

@ -112,6 +112,7 @@ func main() {
switch <-sysSignal {
case os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV:
if currentSong.Artist != "" {
currentSong.Listeners, currentSong.MaxListeners = lstnrs.Reset()
if err := stats.Add(&currentSong); err != nil {
log.Println("failed to save a current song during a shutdown:", err)
}