]> git.ipfire.org Git - people/stevee/guardian.git/blobdiff - guardian
Use Events module to perform various actions.
[people/stevee/guardian.git] / guardian
index 2a5b460da4d37137e43211570007da01d28b155d..07e0c146c74d7c31ae2292d21dafcd19c9c2ddc6 100644 (file)
--- a/guardian
+++ b/guardian
@@ -30,6 +30,7 @@ use Time::HiRes qw[ time sleep ];
 require Guardian::Base;
 require Guardian::Config;
 require Guardian::Daemon;
+require Guardian::Events;
 require Guardian::Logger;
 require Guardian::Parser;
 require Guardian::Socket;
@@ -86,6 +87,9 @@ $mainsettings{Logger} = $logger;
 # Redirect perls "die" messages to the logger before exiting.
 $SIG{__DIE__} = sub { $logger->Log("err", "@_"); };
 
+# Initialize the event handler.
+my $events = Guardian::Events->Init(%mainsettings);
+
 # Shared hash between the main process and all threads. It will store all
 # monitored files and their current file position.
 my %monitored_files :shared = ();
@@ -124,10 +128,18 @@ while(1) {
                # Log processed event.
                $logger->Log("debug", "QUEUE - Processed event: $event");
 
+               # Send event data to the events parser to determine
+               # if any action is required.
+               $events->CheckAction($event);
+
                # Drop processed event from queue.
                $queue->dequeue();
        }
 
+       # Call RemoveBlocks routine from the Events module to check
+       # if items from the block list can be dropped.
+       $events->RemoveBlocks();
+
        # Sleep 10ms to reduce the load of the main process.
        sleep(0.01);
 }