Subject: | Error with .filetaildirwatchdog on windows |
Date: | Mon, 29 Oct 2012 11:21:47 +1100 |
To: | "bug-File-Tail-Dir [...] rt.cpan.org" <bug-File-Tail-Dir [...] rt.cpan.org> |
From: | "Danny Blazejczak (AU)" <danny.blazejczak [...] dimensiondata.com> |
Hi Jon,
Thanks as well for this File::Tail::Dir module. It seems to do exactly what I need.
I am testing this module at the moment on Windows 7 - SP1. The '_start_watchdog' is causing problems on this OS though, when saving state. Maybe this functionality is not intended to work on Windows?
Perl version = v5.16.1 built for MSWin32-x86-multi-thread
Module version = File-Tail-Dir-0.12
When saving state I have this error:
Uncaught exception from user code:
C:\Users\dblazejc\AppData\Local\Temp\rgGwJbGvkJ\.filetaildirwatchdog: No such file or directory at C:/perl/perl/site/lib/File/Tail/Dir.pm line 454.
Cwd::_croak('C:\Users\dblazejc\AppData\Local\Temp\rgGwJbGvkJ\.filetaildirw...') called at C:/perl/perl/lib/Cwd.pm line 630
Cwd::fast_abs_path('C:\Users\dblazejc\AppData\Local\Temp\rgGwJbGvkJ\.filetaildirw...') called at C:/perl/perl/site/lib/File/Tail/Dir.pm line 454
File::Tail::Dir::_start_watchdog('File::Tail::Dir=HASH(0x2cf561c)') called at C:/perl/perl/site/lib/File/Tail/Dir.pm line 411
File::Tail::Dir::watch_files('File::Tail::Dir=HASH(0x2cf561c)') called at multitail.pl line 45
When looking at the code, in File::Tail::Dir.pm , line 454:
my $filename = abs_path(File::Spec->catfile($self->private_dir, $_dotfile));
the abs_path function checks if the file exists (Cwd:: fast_abs_path - line 630). The file (.filetaildirw ) does not exist yet at this point, and hence the failure.
As a workaround, I created this file at the start of my script. In this scenario the script goes a bit further, but fails at '$SIG{USR1}', which is a Unix signal, not recognized on Windows:
No such signal: SIGUSR1 at C:/perl/perl/site/lib/File/Tail/Dir.pm line 472,
<__ANONIO__> line 12 (#1)
(W signal) You specified a signal name as a subscript to %SIG that was
not recognized. Say kill -l in your shell to see the valid signal
names on your system.
I think I use the module correctly, as follows:
my @_DIRECTORIES = ['C:/projects/1/','C:/projects/2/'];
my $tailer = File::Tail::Dir->new(
directories => @_DIRECTORIES,
filter => qr/.*log$/,
autostate => 1,
# 0 - 0=update for every change. (value in sec)
# does not seem to work (no .filetaildirstate) - but no error
# 1 - error ".filetaildirwatchdog: No such file or directory"
autostate_delay => 1,
);
$tailer->watch_files();
When I set the 'autostate_delay => 0', I do not get the error, but also the state file is not saved.
Maybe there is something else I am missing?
Thanks for any help with this,
Danny