Acrux
view release on metacpan or search on metacpan
lib/Acrux/FileLock.pm view on Meta::CPAN
package Acrux::FileLock;
use strict;
use warnings;
use utf8;
=encoding utf-8
=head1 NAME
Acrux::FileLock - The Lock File simple interface
=head1 SYNOPSIS
use Acrux::FileLock;
my $fl = Acrux::FileLock->new(
file => '/tmp/file.lock',
pid => $$,
auto => 0,
);
if ( my $pid = $fl->check ) {
warn $fl->error if $fl->error;
die "Already running: $pid";
}
$fl->lock;
die $fl->error if $fl->error;
# . . . do stuff . . .
$fl->unlock;
die $fl->error if $fl->error;
... or with auto-lock and auto-unlock:
my $fl = Acrux::FileLock->new(
file => '/tmp/file.lock',
pid => $$,
auto => 1,
);
die $fl->error if $fl->error;
die "Already running" if $fl->check;
# . . . do stuff . . .
=head1 DESCRIPTION
The Lock File simple interface
This package manages a lock files. It will create a lock file,
query the process within to discover if it's still running, and remove
the lock file. This module based on L<Lock::File>, L<File::TinyLock>,
L<JIP::LockFile>, L<LockFile::Simple> and L<Acrux::FilePid>.
=head1 METHODS
This module implements the following methods
=head2 new
my $fl = Acrux::FileLock->new(
file => '/tmp/file.lock',
delay => 60,
retries => 5,
( run in 0.994 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )