Author: Bernhard Wick (bw@appserver.io)
Inheritance: extends AppserverIo\Appserver\Core\AbstractContextThread, implements AppserverIo\Appserver\Core\Interfaces\ScannerInterface
コード例 #1
0
 /**
  * Constructor sets initialContext object per default and calls
  * init function to pass other args.
  *
  * @param \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext The initial context instance
  * @param string                                                         $name           The unique scanner name from the configuration
  * @param integer                                                        $interval       The interval in seconds we want to execute the configured jobs
  */
 public function __construct($initialContext, $name, $interval = 1)
 {
     // call parent constructor
     parent::__construct($initialContext, $name);
     // initialize the members
     $this->interval = $interval;
     // immediately start the scanner
     $this->start();
 }
コード例 #2
0
 /**
  * Constructor sets initialContext object per default and calls
  * init function to pass other args.
  *
  * @param \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext    The initial context instance
  * @param string                                                         $name              The unique scanner name from the configuration
  * @param string                                                         $directory         The directory we want to scan
  * @param integer                                                        $interval          The interval in seconds we want scan the directory
  * @param string                                                         $extensionsToWatch The comma separated list with extensions of files we want to watch
  */
 public function __construct($initialContext, $name, $directory, $interval = 1, $extensionsToWatch = '')
 {
     // call parent constructor
     parent::__construct($initialContext, $name);
     // initialize the members
     $this->interval = $interval;
     $this->directory = $directory;
     // explode the comma separated list of file extensions
     $this->extensionsToWatch = explode(',', str_replace(' ', '', $extensionsToWatch));
     // immediately start the scanner
     $this->start();
 }
コード例 #3
0
 /**
  * Constructor sets initialContext object per default and calls
  * init function to pass other args.
  *
  * @param \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext    The initial context instance
  * @param string                                                         $name              The unique scanner name from the configuration
  * @param string                                                         $directory         The directory we want to scan
  * @param integer                                                        $interval          The interval in seconds we want scan the directory
  * @param string                                                         $extensionsToWatch The comma separeted list with extensions of files we want to watch
  * @param integer                                                        $maxFiles          The maximal amount of files to keep (0 means unlimited)
  * @param integer                                                        $maxSize           The maximal size of a log file in byte (limited to a technical max of 2GB)
  */
 public function __construct(ContextInterface $initialContext, $name, $directory, $interval = 1, $extensionsToWatch = '', $maxFiles = 10, $maxSize = LogrotateScanner::MAX_FILE_SIZE)
 {
     // call parent constructor
     parent::__construct($initialContext, $name);
     // initialize the members
     $this->interval = $interval;
     $this->directory = $directory;
     $this->maxFiles = (int) $maxFiles;
     // set the maximum size of log files
     $this->maxSize = (int) $maxSize;
     // pre-initialize the filename format
     $this->filenameFormat = LogrotateScanner::FILENAME_FORMAT_PLACEHOLDER . '.' . LogrotateScanner::SIZE_FORMAT_PLACEHOLDER;
     // explode the comma separated list of file extensions
     $this->extensionsToWatch = explode(',', str_replace(' ', '', $extensionsToWatch));
     // next rotation date is tomorrow
     $tomorrow = new \DateTime('tomorrow');
     $this->nextRotationDate = $tomorrow->getTimestamp();
     // immediately start the scanner
     $this->start();
 }