]>
iEval git - gruntmaster-daemon.git/blob - lib/Gruntmaster/Daemon/Base.pm
3f6416c858534d78b6e6a405ef64c72f4fe8fbe8
1 package Gruntmaster
::Daemon
::Base
;
6 use parent qw
/Exporter/;
7 our @EXPORT_OK = qw
/watch/;
8 our $VERSION = '0.001';
12 use Log
::Log4perl qw
/get_logger/;
14 ##################################################
17 my ($name, $dir, $cb) = @_;
18 my $logger = get_logger
;
19 $logger->debug("Taking job $name...");
20 open my $file, ">>$dir/$name/meta.yml";
21 if (flock $file, LOCK_EX
|LOCK_NB
){
22 $logger->debug("Successfully taken job $name, executing callback");
25 $logger->debug("Job $name already taken");
34 process
$_, $dir, $cb;
37 my $logger = Log
::Log4perl
->get_logger(__PACKAGE__
);
38 my $inotify = Linux
::Inotify2
->new or $logger->logdie("Unable to create Linux::Inotify2 object: $!");
39 $inotify->watch($dir, IN_MOVED_TO
, sub { process
$_[0]->name, $dir, $cb }) or $logger->logdie("Error watching $dir: $!");
40 1 while $inotify->poll;
41 $logger->logdie("Inotify polling stopped: $!");
This page took 0.050881 seconds and 4 git commands to generate.