has $cfg_file :reader;
has $opt :reader;
has $db :reader;
- has $db_needs_update = 1;
+ has $db_needs_update :writer = 1;
has $mpd :reader;
use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf';
$mpd = Net::Async::MPD->new(%conn);
+ $mpd->on(
+ close => sub {
+ die "Connection to MPD lost";
+ }
+ );
+
my $int_signal_handler = sub {
state $signal_count = 0;
$signal_count++;
);
}
- method run {
- $mpd->on(
- close => sub {
- die "Connection to MPD lost";
- }
- );
-
- $self->prepare_to_wait_idle;
- }
-
method stop {
undef $mpd;
}
method run_loop {
+ $self->connect_mpd;
$self->connect_db;
for ( ;; ) {
- $self->queue_songs( undef, sub { $self->run } );
+ $self->queue_songs( undef, sub { $self->prepare_to_wait_idle } );
$log->debug("Entering event loop. PID=$$");