mirror of
https://github.com/navidrome/navidrome.git
synced 2025-12-23 23:18:05 -05:00
Terminate all MPV instances when stopping Navidrome (#3008)
* Terminate all mpv instances when stopping Navidrome * Exit trackSwitcher goroutine when terminating * Remove potential race condition when starting the Playback device * Fix lint error * Removed unused and unneeded vars/functions * Use device short name in log * Small refactor * Small nitpick * Make start functions more uniform
This commit is contained in:
19
cmd/root.go
19
cmd/root.go
@@ -83,12 +83,9 @@ func runNavidrome() {
|
||||
g.Go(startServer(ctx))
|
||||
g.Go(startSignaller(ctx))
|
||||
g.Go(startScheduler(ctx))
|
||||
g.Go(startPlaybackServer(ctx))
|
||||
g.Go(schedulePeriodicScan(ctx))
|
||||
|
||||
if conf.Server.Jukebox.Enabled {
|
||||
g.Go(startPlaybackServer(ctx))
|
||||
}
|
||||
|
||||
if err := g.Wait(); err != nil && !errors.Is(err, interrupted) {
|
||||
log.Error("Fatal error in Navidrome. Aborting", err)
|
||||
}
|
||||
@@ -151,21 +148,21 @@ func schedulePeriodicScan(ctx context.Context) func() error {
|
||||
}
|
||||
|
||||
func startScheduler(ctx context.Context) func() error {
|
||||
log.Info(ctx, "Starting scheduler")
|
||||
schedulerInstance := scheduler.GetInstance()
|
||||
|
||||
return func() error {
|
||||
log.Info(ctx, "Starting scheduler")
|
||||
schedulerInstance := scheduler.GetInstance()
|
||||
schedulerInstance.Run(ctx)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func startPlaybackServer(ctx context.Context) func() error {
|
||||
log.Info(ctx, "Starting playback server")
|
||||
|
||||
playbackInstance := GetPlaybackServer()
|
||||
|
||||
return func() error {
|
||||
if !conf.Server.Jukebox.Enabled {
|
||||
return nil
|
||||
}
|
||||
log.Info(ctx, "Starting playback server")
|
||||
playbackInstance := GetPlaybackServer()
|
||||
return playbackInstance.Run(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user