Watcher plugin fixes
* com.noccy.watcher: Initial inotify support * ScriptRunner now accepts an array of local vars for expansion when evaluating scripts
This commit is contained in:
@ -17,10 +17,12 @@ class FileWatcher {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (extension_loaded('inotify')) {
|
||||
$this->monitor = new MtimeMonitor();
|
||||
//$this->monitor = new InotifyMonitor();
|
||||
if (extension_loaded('inotify') && !getenv("SPARK_NO_INOTIFY")) {
|
||||
//$this->monitor = new MtimeMonitor();
|
||||
printf("Enabling inotify support, watching directories\n");
|
||||
$this->monitor = new InotifyMonitor();
|
||||
} else {
|
||||
printf("No inotify support, watching file mtimes\n");
|
||||
$this->monitor = new MtimeMonitor();
|
||||
}
|
||||
$this->scriptRunner = get_environment()->getScriptRunner();
|
||||
@ -38,7 +40,11 @@ class FileWatcher {
|
||||
private function triggerRule(Rule $rule)
|
||||
{
|
||||
$actions = $rule->getActions();
|
||||
$this->scriptRunner->evaluate($actions);
|
||||
$locals = [
|
||||
'WATCHER_RULE' => $rule->getName(),
|
||||
'WATCHER_FILES' => join(" ",$rule->getWatchedFiles()),
|
||||
];
|
||||
$this->scriptRunner->evaluate($actions, $locals);
|
||||
}
|
||||
|
||||
public function loop()
|
||||
|
Reference in New Issue
Block a user