Subject: | Use multiple PID files in one process |
Hiya
Proc::PID::File is a great little utility, so great that I want to use
it multiple times in a single process...
I'm using it to only allow a single instance of cronjob X to run, but I
also want to be able to lock a working dir, so that manual job Y can't
run on the same dir.
Unfortunately, your use of a scalar $self prevents me from doing so. I
think that really, you only want to make sure that there is a single
version of each PID file.
I suggest the following:
- instead of declaring a package wide my $self, use:
my %selves
- then, in sub running, do the following:
sub running {
my $self = shift->new(@_);
my $path = $self->{path};
$self = $selves{$path} ||= $self;