* Switch to sane over gaze for file watching: Gaze was not triggering on file additions
* Remove watching of config files for now -- doesn't work anyway. Will revisit later.
This commit is contained in:
parent
d5334270c4
commit
067bb9e884
|
@ -6,7 +6,6 @@ var Log = require('./logger.js').log;
|
|||
|
||||
var paths = require('path');
|
||||
var fs = require('graceful-fs');
|
||||
var Gaze = require('gaze').Gaze;
|
||||
var events = require('events');
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
|
@ -18,7 +17,7 @@ function ConfigCache() {
|
|||
|
||||
var self = this;
|
||||
this.cache = {}; // filePath -> HJSON
|
||||
this.gaze = new Gaze();
|
||||
//this.gaze = new Gaze();
|
||||
|
||||
this.reCacheConfigFromFile = function(filePath, cb) {
|
||||
fs.readFile(filePath, { encoding : 'utf-8' }, function fileRead(err, data) {
|
||||
|
@ -32,7 +31,7 @@ function ConfigCache() {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
this.gaze.on('error', function gazeErr(err) {
|
||||
|
||||
});
|
||||
|
@ -50,6 +49,7 @@ function ConfigCache() {
|
|||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,13 +58,13 @@ util.inherits(ConfigCache, events.EventEmitter);
|
|||
ConfigCache.prototype.getConfigWithOptions = function(options, cb) {
|
||||
assert(_.isString(options.filePath));
|
||||
|
||||
var self = this;
|
||||
// var self = this;
|
||||
var isCached = (options.filePath in this.cache);
|
||||
|
||||
if(options.forceReCache || !isCached) {
|
||||
this.reCacheConfigFromFile(options.filePath, function fileCached(err, config) {
|
||||
if(!err && !isCached) {
|
||||
self.gaze.add(options.filePath);
|
||||
//self.gaze.add(options.filePath);
|
||||
}
|
||||
cb(err, config, true);
|
||||
});
|
||||
|
@ -82,4 +82,4 @@ ConfigCache.prototype.getModConfig = function(fileName, cb) {
|
|||
this.getConfig(paths.join(Config.paths.mods, fileName), cb);
|
||||
};
|
||||
|
||||
module.exports = exports = new ConfigCache();
|
||||
module.exports = exports = new ConfigCache();
|
||||
|
|
|
@ -10,8 +10,9 @@ const _ = require('lodash');
|
|||
const later = require('later');
|
||||
const path = require('path');
|
||||
const pty = require('ptyw.js');
|
||||
const gaze = require('gaze');
|
||||
const sane = require('sane');
|
||||
const moment = require('moment');
|
||||
const paths = require('path');
|
||||
|
||||
exports.getModule = EventSchedulerModule;
|
||||
exports.EventSchedulerModule = EventSchedulerModule; // allow for loadAndStart
|
||||
|
@ -209,13 +210,13 @@ EventSchedulerModule.prototype.startup = function(cb) {
|
|||
Log.warn( { eventName : schedEvent.name }, 'Invalid scheduled event entry');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Log.debug(
|
||||
{
|
||||
eventName : schedEvent.name,
|
||||
schedule : this.moduleConfig.events[schedEvent.name].schedule,
|
||||
action : schedEvent.action,
|
||||
next : moment(later.schedule(schedEvent.schedule.sched).next(1)).format('ddd, MMM Do, YYYY @ h:m:ss a')
|
||||
next : schedEvent.schedule.sched ? moment(later.schedule(schedEvent.schedule.sched).next(1)).format('ddd, MMM Do, YYYY @ h:m:ss a') : 'N/A',
|
||||
},
|
||||
'Scheduled event loaded'
|
||||
);
|
||||
|
@ -226,12 +227,21 @@ EventSchedulerModule.prototype.startup = function(cb) {
|
|||
}, schedEvent.schedule.sched));
|
||||
}
|
||||
|
||||
if(schedEvent.schedule.watchFile) {
|
||||
gaze(schedEvent.schedule.watchFile, (err, watcher) => {
|
||||
// :TODO: should track watched files & stop watching @ shutdown
|
||||
watcher.on('all', (watchEvent, watchedPath) => {
|
||||
if(schedEvent.schedule.watchFile === watchedPath) {
|
||||
self.performAction(schedEvent, `Watch file: ${watchedPath}`);
|
||||
if(schedEvent.schedule.watchFile) {
|
||||
const watcher = sane(
|
||||
paths.dirname(schedEvent.schedule.watchFile),
|
||||
{
|
||||
glob : `**/${paths.basename(schedEvent.schedule.watchFile)}`
|
||||
}
|
||||
);
|
||||
|
||||
// :TODO: should track watched files & stop watching @ shutdown?
|
||||
|
||||
[ 'change', 'add', 'delete' ].forEach(event => {
|
||||
watcher.on(event, (fileName, fileRoot) => {
|
||||
const eventPath = paths.join(fileRoot, fileName);
|
||||
if(schedEvent.schedule.watchFile === eventPath) {
|
||||
self.performAction(schedEvent, `Watch file: ${eventPath}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -30,7 +30,7 @@ const fs = require('graceful-fs');
|
|||
const later = require('later');
|
||||
const temptmp = require('temptmp').createTrackedSession('ftn_bso');
|
||||
const assert = require('assert');
|
||||
const gaze = require('gaze');
|
||||
const sane = require('sane');
|
||||
const fse = require('fs-extra');
|
||||
const iconv = require('iconv-lite');
|
||||
const uuidV4 = require('uuid/v4');
|
||||
|
@ -1654,10 +1654,18 @@ FTNMessageScanTossModule.prototype.startup = function(cb) {
|
|||
}
|
||||
|
||||
if(_.isString(importSchedule.watchFile)) {
|
||||
gaze(importSchedule.watchFile, (err, watcher) => {
|
||||
watcher.on('all', (event, watchedPath) => {
|
||||
if(importSchedule.watchFile === watchedPath) {
|
||||
tryImportNow(`Performing import/toss due to @watch: ${watchedPath} (${event})`);
|
||||
const watcher = sane(
|
||||
paths.dirname(importSchedule.watchFile),
|
||||
{
|
||||
glob : `**/${paths.basename(importSchedule.watchFile)}`
|
||||
}
|
||||
);
|
||||
|
||||
[ 'change', 'add', 'delete' ].forEach(event => {
|
||||
watcher.on(event, (fileName, fileRoot) => {
|
||||
const eventPath = paths.join(fileRoot, fileName);
|
||||
if(paths.join(fileRoot, fileName) === importSchedule.watchFile) {
|
||||
tryImportNow(`Performing import/toss due to @watch: ${eventPath} (${event})`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,9 +23,11 @@
|
|||
"binary": "0.3.x",
|
||||
"buffers": "NuSkooler/node-buffers",
|
||||
"bunyan": "^1.8.10",
|
||||
"exiftool": "^0.0.3",
|
||||
"farmhash": "^1.2.1",
|
||||
"fs-extra": "^3.0.1",
|
||||
"gaze": "^1.1.2",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"hashids": "^1.1.1",
|
||||
"hjson": "^2.4.2",
|
||||
"iconv-lite": "^0.4.17",
|
||||
|
@ -35,18 +37,17 @@
|
|||
"mime-types": "^2.1.15",
|
||||
"minimist": "1.2.x",
|
||||
"moment": "^2.18.1",
|
||||
"node-glob": "^1.2.0",
|
||||
"nodemailer": "^4.0.1",
|
||||
"ptyw.js": "NuSkooler/ptyw.js",
|
||||
"sane": "^2.2.0",
|
||||
"sanitize-filename": "^1.6.1",
|
||||
"sqlite3": "^3.1.1",
|
||||
"ssh2": "^0.5.5",
|
||||
"temptmp": "^1.0.0",
|
||||
"uuid": "^3.0.1",
|
||||
"uuid-parse": "^1.0.0",
|
||||
"ws" : "^3.0.0",
|
||||
"graceful-fs" : "^4.1.11",
|
||||
"exiftool" : "^0.0.3",
|
||||
"node-glob" : "^1.2.0"
|
||||
"ws": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
|
|
Loading…
Reference in New Issue