From: Damyan Ivanov <dmn@debian.org>
Date: Thu, 11 Nov 2021 14:46:46 +0000 (+0000)
Subject: dump configuration to STDERR on SIGUSR1
X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=c701e760eddc52329e471c0b33aa17a1b07e4921;p=mpd-feeder.git

dump configuration to STDERR on SIGUSR1
---

diff --git a/bin/mpd-feeder b/bin/mpd-feeder
index da60df8..d6f5d6f 100755
--- a/bin/mpd-feeder
+++ b/bin/mpd-feeder
@@ -180,6 +180,22 @@ use Net::Async::MPD;
                 },
             )
         );
+
+        $mpd->loop->add(
+            IO::Async::Signal->new(
+                name       => 'USR1',
+                on_receipt => sub {
+                    $log->debug("SIGUSR1 received. Dumping configuration to STDERR");
+                    my $old = select \*STDERR;
+                    try {
+                        $opt->dump;
+                    }
+                    finally {
+                        select $old;
+                    }
+                },
+            )
+        );
     }
 
     method connect_db {