X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FScheduler.pm;fp=lib%2FCatalyst%2FPlugin%2FScheduler.pm;h=89e919d0efc0b71047c08dc1878308d2392ca35b;hb=8cefc92134209bfa9dffad2325296cb3fdf36a0d;hp=8b446b755c9e1fe5aadd59c048e282bdd2d2e393;hpb=bec4be8c6d6006d2ba484ad0c2edae93c3ca2563;p=catagits%2FCatalyst-Plugin-Scheduler.git diff --git a/lib/Catalyst/Plugin/Scheduler.pm b/lib/Catalyst/Plugin/Scheduler.pm index 8b446b7..89e919d 100644 --- a/lib/Catalyst/Plugin/Scheduler.pm +++ b/lib/Catalyst/Plugin/Scheduler.pm @@ -11,7 +11,7 @@ use NEXT; use Set::Scalar; use Storable qw/lock_store lock_retrieve/; -our $VERSION = '0.07'; +our $VERSION = '0.08'; __PACKAGE__->mk_classdata( '_events' => [] ); __PACKAGE__->mk_accessors('_event_state'); @@ -157,6 +157,20 @@ sub setup { $c->config->{scheduler}->{state_file} ||= $c->path_to('scheduler.state'); $c->config->{scheduler}->{hosts_allow} ||= '127.0.0.1'; $c->config->{scheduler}->{yaml_file} ||= $c->path_to('scheduler.yml'); + + # Always start with a clean state + if ( -e $c->config->{scheduler}->{state_file} ) { + $c->log->debug( + 'Scheduler: Removing old state file ' . + $c->config->{scheduler}->{state_file} + ) if $c->config->{scheduler}->{logging}; + + unlink $c->config->{scheduler}->{state_file} + or Catalyst::Exception->throw( + message => 'Scheduler: Unable to remove old state file ' + . $c->config->{scheduler}->{state_file} . " ($!)" + ); + } $c->NEXT::setup(@_); }