X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP%2FRestarter%2FWatcher.pm;h=672ec08b45dbba59c6dc25242ec285bf5659dde7;hb=add14c15fb7fb9708aa24e2043ae66c132bed0de;hp=3062dc6f5ee7f6292eec0bdfe20501ef2f303f24;hpb=b5ecfcf07b8ffe7e9984f0279c8781ce51c6ac6a;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm b/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm index 3062dc6..672ec08 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm @@ -13,6 +13,7 @@ __PACKAGE__->mk_accessors( directory modified regex + follow_symlinks watch_list/ ); @@ -47,8 +48,10 @@ sub watch { my @changes; my @changed_files; + + my $delay = ( defined $self->delay ) ? $self->delay : 1; - sleep $self->delay || 1; + sleep $delay if $delay > 0; eval { @changes = $self->modified->changed }; if ($@) { @@ -100,7 +103,9 @@ sub watch { sub _index_directory { my $self = shift; - my $dir = $self->directory || die "No directory specified"; + my $dir = $self->directory; + die "No directory specified" if !$dir or ref($dir) && !@{$dir}; + my $regex = $self->regex || '\.pm$'; my %list; @@ -118,9 +123,10 @@ sub _index_directory { $cur_dir =~ s{/script/..}{}; $list{$cur_dir} = 1; }, + follow_fast => $self->follow_symlinks ? 1 : 0, no_chdir => 1 }, - $dir + ref $dir eq 'ARRAY' ? @{$dir} : $dir ); return \%list; } @@ -151,7 +157,7 @@ files my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new( directory => '/path/to/MyApp', - regex => '\.yml$|\.yaml$|\.pm$', + regex => '\.yml$|\.yaml$|\.conf|\.pm$', delay => 1, );