| Archer documentation | Contained in the Archer distribution. |
Archer::Plugin::Flock - do not run two process in the same time.
- module: Flock
config:
file: /tmp/archer.lock
Tokuhiro Matsuno.
| Archer documentation | Contained in the Archer distribution. |
package Archer::Plugin::Flock; use strict; use warnings; use base qw/Archer::Plugin/; use Fcntl ":flock"; sub run { my ($self, $context) = @_; my $filename = $self->{config}->{file} or die "missing filename"; open my $fh , '>' , $filename or die $!; flock( $fh, LOCK_EX|LOCK_NB ) or die "cannot get the lock\n"; $context->{__PACKAGE__} = $fh; # do not close the lock file :) } 1; __END__