Wednesday, 7 June 2017

Node js watch files in mounted folder

Hello I'm using a node JS server that is watching file changes from mounted folder but it doesn't detect the changes because the files should be a local files.

Can anybody ask me a solution because I should do it like this onde node js who detects changes files from another pc

there is the code:

var express = require('express');  
var app = express();  
var server = require('http').Server(app);  
var io = require('socket.io')(server);
var fs = require('fs');
var watch = require('node-watch');

var last={  
  id: "1",
  content:""
}
io.on('connection', function(socket) {  

  console.log('Some one is connected by Sockets');
  socket.emit('telegrama', lastGDC);


});

watch('data/position.csv', { recursive: true }, function(evt, name) {
    console.log('%s changed.', name);
    /* last.content=fileChangedContent;*/
    io.sockets.emit('telegrama', last);

});
server.listen(8080, function() {  
    console.log("running server ://localhost:8080");
});


via ORIOL DOMINGO ADELL

No comments:

Post a Comment