use NEXT;
use Set::Scalar;
use Storable qw/lock_store lock_retrieve/;
-use YAML;
-our $VERSION = '0.06';
+our $VERSION = '0.07';
__PACKAGE__->mk_classdata( '_events' => [] );
__PACKAGE__->mk_accessors('_event_state');
for my $event ( @{ $c->_events } ) {
my $next_run;
- if ( $event->{trigger}
+ if ( $event->{trigger} && $c->req->params->{schedule_trigger}
&& $event->{trigger} eq $c->req->params->{schedule_trigger} )
{
= $c->_event_state->{events}->{ $event->{event} }->{last_run};
if ( $last_run ) {
$last_run = DateTime->from_epoch(
- epoch => $last_run,
+ epoch => $last_run,
time_zone => $conf->{time_zone},
);
$dump->{last_run}
if ( $mtime > $c->_event_state->{yaml_mtime}->{$$} ) {
$c->_event_state->{yaml_mtime}->{$$} = $mtime;
- # clean up old PID files listed in yaml_mtime
+ # clean up old PIDs listed in yaml_mtime
foreach my $pid ( keys %{ $c->_event_state->{yaml_mtime} } ) {
if ( $c->_event_state->{yaml_mtime}->{$pid} < $mtime ) {
delete $c->_event_state->{yaml_mtime}->{$pid};
# wipe out all current events and reload from YAML
$c->_events( [] );
- my $yaml = YAML::LoadFile( $c->config->{scheduler}->{yaml_file} );
+ my $file = $c->config->{scheduler}->{yaml_file};
+ my $yaml;
+
+ eval { require YAML::Syck; };
+ if( $@ ) {
+ require YAML;
+ $yaml = YAML::LoadFile( "$file" );
+ }
+ else {
+ open( my $fh, $file ) or die $!;
+ my $content = do { local $/; <$fh> };
+ close $fh;
+ $yaml = YAML::Syck::Load( $content );
+ }
foreach my $event ( @{$yaml} ) {
$c->schedule( %{$event} );