Hi,

I tail a log file on server and dipslay the log lines on the browser. The 
problem is: Every time I refresh my browser, I get one more duplicate log 
line. For example, on initial load, I get one log line on the browser for 
every line in the log file. If I refresh the browser, I get 2 line on the 
browser for every line in the log file. If I refresh again, I get 3 lines 
on the browser for every line in the log file. I have been looking at this 
for days now. Please help.


Here is my server code:
//Routing
     app.get('/', function (req, res) {
         res.redirect('/index.html');
     });
     
     server = http.createServer(app).listen(app.get('port'), function() {
       console.log('Express server listening on port ' + app.get('port'));
     });
     
     socketio = require('socket.io')
     io = socketio.listen(server)
     
     logFile = "test.log";
     io.sockets.on('connection', function(socket) { 
         Tail = require('tail').Tail
         tail = new Tail(logFile);
         tail.on('line', function(data){ 
             return io.sockets.emit('new-data', {channel: "stdout", value: 
data, logFile: logFile }); 
         
});                                                                             
                                                                                
                                                                    

     });


Here is my client code:
         wireSocketIo: function() {
             var logPanel = 
Ext.ComponentQuery.query("#logPanel")[0];                                       
                                                                                
                                                     

     
             var socket = io.connect('http://localhost:3000');
             socket.on('new-data', function(data) {     
                 var newLogLine = Ext.create("Ext.Component", {html: 
"<div>" + data.value + "</div>"});
                 logPanel.add(newLogLine);
             }); 
         },

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/5bf22709-9846-4cb9-bb10-04e79512bb96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to