| App-MadEye documentation | Contained in the App-MadEye distribution. |
App::MadEye::Plugin::Check::Flock - lock.
- module: Check::Flock
config:
file: /var/run/madeye
type: map
mapping:
file:
required: yes
type: str
Tokuhiro Matsuno
| App-MadEye documentation | Contained in the App-MadEye distribution. |
package App::MadEye::Plugin::Check::Flock; use strict; use warnings; use base qw/App::MadEye::Plugin::Base/; use LWP::UserAgent; use Fcntl ":flock"; sub check : Hook { my ($self, $context, $args) = @_; my $file_name = $self->config->{config}->{file} or die "missing file"; open $self->{lock_fh} , '>' , $file_name or die $!; my $status = flock( $self->{lock_fh}, LOCK_EX|LOCK_NB ) or die "cannot get the lock"; } sub after_run_jobs : Hook { my ($self, $context, $args) = @_; close($self->{lock_fh}); # release lock } 1; __END__