Changeset 7560 for lang/perl

Show
Ignore:
Timestamp:
03/06/08 15:22:45 (5 years ago)
Author:
tokuhirom
Message:

今日の昼飯は五反田のきららで、ぎゃん辛ラーメンたべた。なお、いろいろなワーカーに対応できるようにフック使うことにした。

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

Legend:

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

    r7557 r7560  
    1414#     timeout: 4 
    1515 
    16 # - module: Worker::Gearman 
    17 #   config: 
    18 #     fork_num: 3 
    19 #     gearman_servers: 
    20 #       - 127.0.0.1 
     16  - module: Worker::Gearman 
     17    config: 
     18      fork_num: 3 
     19      gearman_servers: 
     20        - 127.0.0.1 
    2121 
    2222# - module: Agent::HTTP 
  • lang/perl/App-MadEye/trunk/lib/App/MadEye.pm

    r7559 r7560  
    1919    $self->run_hook('check'); 
    2020 
    21     $self->run_workers(); 
     21    $self->run_hook('before_run_jobs'); 
    2222 
    23     $self->run_hook('run_jobs'); 
     23        $self->run_hook('run_jobs'); 
    2424 
    25     $self->wait_jobs(); 
    26  
    27     $self->kill_workers(); 
    28  
    29     $self->wait_workers(); 
     25    $self->run_hook('after_run_jobs'); 
    3026 
    3127    $self->run_hook('notify' => $self->{results}); 
  • lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Worker/Gearman.pm

    r7559 r7560  
    1515our $TIMEOUT = 60;  # TODO: configurable 
    1616 
    17 sub run_workers : Method { 
     17sub run_workers : Hook('before_run_jobs') { 
    1818    my ($self, $context) = @_; 
    1919 
     
    6969} 
    7070 
    71 sub wait_jobs :Method { 
     71sub after_run_jobs : Hook('after_run_jobs') { 
     72    my ($self, $context, $args) = @_; 
     73 
     74    $context->log(debug => 'kill children!'); 
     75 
     76    $self->wait_jobs($context); 
     77    $self->kill_workers($context); 
     78    $self->wait_workers($context); 
     79} 
     80 
     81sub wait_jobs { 
    7282    my ($self, $context) = @_; 
    7383 
    74     $self->task_set->wait; 
     84    $self->task_set($context)->wait; 
    7585} 
    7686 
    77 sub kill_workers :Method { 
     87sub kill_workers { 
    7888    my ( $self, $context ) = @_; 
    7989 
     
    101111} 
    102112 
    103 sub wait_workers : Method { 
     113sub wait_workers { 
    104114    my ( $self, $context ) = @_; 
    105115 
  • lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Worker/Simple.pm

    r7559 r7560  
    77 
    88our $TIMEOUT = 60;  # TODO: configurable 
    9  
    10 # nop. 
    11 sub run_workers  : Method { } 
    12 sub wait_jobs    : Method { } 
    13 sub kill_workers : Method { } 
    14 sub wait_workers : Method { } 
    159 
    1610sub run_job :Method {