Quit by disabling all sources
This commit is contained in:
parent
d2090bee67
commit
bfd0bb866a
22
app.go
22
app.go
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"git.nemunai.re/nemunaire/hathoris/api"
|
||||
"git.nemunai.re/nemunaire/hathoris/config"
|
||||
"git.nemunai.re/nemunaire/hathoris/sources"
|
||||
"git.nemunai.re/nemunaire/hathoris/ui"
|
||||
)
|
||||
|
||||
@ -60,6 +61,27 @@ func (app *App) Start() {
|
||||
}
|
||||
|
||||
func (app *App) Stop() {
|
||||
// Disable all sources
|
||||
someEnabled := false
|
||||
for k, src := range sources.SoundSources {
|
||||
if src.IsEnabled() {
|
||||
someEnabled = true
|
||||
go func(k string, src sources.SoundSource) {
|
||||
log.Printf("Stopping %s...", k)
|
||||
err := src.Disable()
|
||||
if err != nil {
|
||||
log.Printf("Unable to disable %s source", k)
|
||||
}
|
||||
log.Printf("%s stopped", k)
|
||||
}(k, src)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for fadeout
|
||||
if someEnabled {
|
||||
time.Sleep(2000 * time.Millisecond)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := app.srv.Shutdown(ctx); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user