projects
/
gruntmaster-daemon.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor Format
[gruntmaster-daemon.git]
/
lib
/
Gruntmaster
/
Daemon
/
Base.pm
diff --git
a/lib/Gruntmaster/Daemon/Base.pm
b/lib/Gruntmaster/Daemon/Base.pm
index b7db7892c30b72c1a8e22fc201d1b8f52d3049fe..3f6416c858534d78b6e6a405ef64c72f4fe8fbe8 100644
(file)
--- a/
lib/Gruntmaster/Daemon/Base.pm
+++ b/
lib/Gruntmaster/Daemon/Base.pm
@@
-7,7
+7,7
@@
use parent qw/Exporter/;
our @EXPORT_OK = qw/watch/;
our $VERSION = '0.001';
our @EXPORT_OK = qw/watch/;
our $VERSION = '0.001';
-use Fcntl qw/
O_WRONLY O_EXCL O_CREAT
/;
+use Fcntl qw/
:flock
/;
use Linux::Inotify2;
use Log::Log4perl qw/get_logger/;
use Linux::Inotify2;
use Log::Log4perl qw/get_logger/;
@@
-17,12
+17,14
@@
sub process{
my ($name, $dir, $cb) = @_;
my $logger = get_logger;
$logger->debug("Taking job $name...");
my ($name, $dir, $cb) = @_;
my $logger = get_logger;
$logger->debug("Taking job $name...");
- if (sysopen my $file, "$dir/$name/pidfile", O_WRONLY | O_EXCL | O_CREAT){
+ open my $file, ">>$dir/$name/meta.yml";
+ if (flock $file, LOCK_EX|LOCK_NB){
$logger->debug("Successfully taken job $name, executing callback");
$cb->("$dir/$name");
} else {
$logger->debug("Job $name already taken");
}
$logger->debug("Successfully taken job $name, executing callback");
$cb->("$dir/$name");
} else {
$logger->debug("Job $name already taken");
}
+ close $file;
}
sub watch{
}
sub watch{
This page took
0.009848 seconds
and
4
git commands to generate.