Changeset 1016 for trunk


Ignore:
Timestamp:
05/22/12 01:00:13 (12 years ago)
Author:
nanardon
Message:
  • trap perl error in la-sync-manager
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SyncManager.pm

    r861 r1016  
    4545    my ($self, $module, $dbrev) = @_; 
    4646 
    47     if (!$self->ini->SectionExists($module)) { 
    48         la_log LA_ERR, "Cannot run inexistant module %s", $module; 
     47    eval { 
     48        if (!$self->ini->SectionExists($module)) { 
     49            la_log LA_ERR, "Cannot run inexistant module %s", $module; 
     50            return; 
     51        } 
     52 
     53        my $modtype = $self->ini->val($module, 'type', $module); 
     54        my $task = LATMOS::Accounts::Task->new( 
     55            $modtype, 
     56            config => $self->{config}, 
     57        ) 
     58            or do { 
     59            la_log(LA_ERR, 'Cannot load module %s', $modtype); 
     60            return; 
     61        }; 
     62        la_log LA_NOTICE, "Processing sync module %s (%s)", $module, $modtype; 
     63        if (!$task->init) { 
     64            la_log(LA_ERR, 'init() failed for module %s', $module); 
     65            return; 
     66        } 
     67 
     68        if (!$task->needupd($dbrev, $self)) { 
     69            la_log LA_DEBUG, "No change on main base, aborting"; 
     70            return 1; 
     71        } 
     72 
     73 
     74        my $res = $task->run; 
     75        if (!$res) { 
     76            la_log LA_ERR, "Task %s did not end successfully", $module; 
     77        } 
     78        $task->post if ($res); 
     79        la_log LA_DEBUG, "end process $module"; 
     80        return $res; 
     81    }; 
     82 
     83    if ($@) { 
     84        la_log(LA_CRIT, 'Fatal Perl Error: %s', $@); 
    4985        return; 
    5086    } 
    51  
    52     my $modtype = $self->ini->val($module, 'type', $module); 
    53     my $task = LATMOS::Accounts::Task->new( 
    54         $modtype, 
    55         config => $self->{config}, 
    56     ) 
    57         or do { 
    58         la_log(LA_ERR, 'Cannot load module %s', $modtype); 
    59         return; 
    60     }; 
    61     la_log LA_NOTICE, "Processing sync module %s (%s)", $module, $modtype; 
    62     if (!$task->init) { 
    63         la_log(LA_ERR, 'init() failed for module %s', $module); 
    64         return; 
    65     } 
    66  
    67     if (!$task->needupd($dbrev, $self)) { 
    68         la_log LA_DEBUG, "No change on main base, aborting"; 
    69         return 1; 
    70     } 
    71  
    72  
    73     my $res = $task->run; 
    74     if (!$res) { 
    75         la_log LA_ERR, "Task %s did not end successfully", $module; 
    76     } 
    77     $task->post if ($res); 
    78     la_log LA_DEBUG, "end process $module"; 
    79     return $res; 
    8087} 
    8188 
Note: See TracChangeset for help on using the changeset viewer.