NAME
App::DistSync::Lock - Lock File Manipulation
VERSION
Version 1.00
SYNOPSIS
use File::Pid;
my $lock = new App::DistSync::Lock(
file => '/some/file.lock',
hold => 3600,
pid => $$,
);
if ( my $pid = $lock->running ) {
die "Already running: $num\n";
}
DESCRIPTION
This module manages a lock file. 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 File::Pid and LockFile::Simple.
new
my $lock = new App::DistSync::Lock;
my $lock = new App::DistSync::Lock(
file => '/var/run/daemon.pid',
hold => 3600,
pid => $$,
);
This constructor takes three optional paramters.
file
- The name of the lock file to work on. If not specified, a lock file located in current directory will be created that matches MANIFEST.LOCK
.
hold
- Max amount of seconds before breaking lock (0 for never, default is 3600)
pid
- The pid to write to a new lockfile. If not specified, $$
is used when the lock file doesn't exist. When the lock file does exist, the pid inside it is used.
running
my $pid = $lock->running;
die "Service already running: $pid\n" if $pid;
Checks to see if the pricess identified in the lock file is still running. If the process is still running, the pid is returned. Otherwise undef
or 0 is returned.
status
my $status = $lock->status;
Returns current status
error
my $error = $lock->error;
Returns current error message
HISTORY
See CHANGES
file
TO DO
See TODO
file
BUGS
* none noted
SEE ALSO
perl
, File::Pid, LockFile::Simple
AUTHOR
Serz Minus (Lepenkov Sergey) http://www.serzik.com <minus@mail333.com>
COPYRIGHT
Copyright (C) 1998-2014 D&D Corporation. All Rights Reserved
LICENSE
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
See LICENSE
file