Changeset 8012

Show
Ignore:
Timestamp:
03/17/08 11:42:21 (5 years ago)
Author:
tokuhirom
Message:

タイムアウト関連の設定は config.yaml にもたせるように。

Location:
lang/perl/App-MadEye/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/App-MadEye/trunk/config.yaml

    r8011 r8012  
    1717    config: 
    1818      fork_num: 3 
     19      task_timeout: 20 
     20      child_timeout: 7 
    1921      gearman_servers: 
    2022        - 127.0.0.1 
  • lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Worker/Gearman.pm

    r8011 r8012  
    1616__PACKAGE__->mk_accessors(qw/task_set child_pids gearman_client/); 
    1717 
    18 our $TASK_TIMEOUT = 60;  # TODO: configurable 
    1918our $CHILD_TIMEOUT = 60;  # TODO: configurable 
    2019 
     
    6564        'watch', 
    6665        freeze($args), +{ 
    67             timeout => $TASK_TIMEOUT, 
     66            timeout => $self->task_timeout(), 
    6867            on_fail => sub { 
    6968                warn "GEARMAN ERROR: " . Dump($args); 
     
    136135 
    137136            $context->log( debug => "watching $args->{target} by $args->{plugin}" ); 
    138  
    139137            my $result = \undef; 
    140             timeout $TASK_TIMEOUT, "watching $args->{target} $args->{plugin}", sub { 
     138            timeout $self->task_timeout(), "watching $args->{target} $args->{plugin}", sub { 
    141139                if ( my $message = $args->{plugin}->is_dead( $args->{target} ) ) { 
    142140                    $result = +{ 
     
    151149    ); 
    152150 
    153     timeout $CHILD_TIMEOUT, 'work child', sub { 
     151    timeout $self->child_timeout(), 'work child', sub { 
    154152        $worker->work while 1; 
    155153    }; 
     154} 
     155 
     156sub task_timeout { 
     157    my $self = shift; 
     158    $self->config->{config}->{task_timeout} || 10; 
     159} 
     160 
     161sub child_timeout { 
     162    my $self = shift; 
     163    $self->config->{config}->{child_timeout} || 60; 
    156164} 
    157165 
     
    177185                - type: str 
    178186            required: yes 
     187        task_timeout: 
     188            type: int 
     189            required: no 
     190        child_timeout: 
     191            type: int 
     192            required: no 
    179193 
    180194=head1 AUTHOR