Skip to content

Instantly share code, notes, and snippets.

@converge
Created November 16, 2018 16:28
Show Gist options
  • Save converge/6ddfcf465fc9cf6ba40c7e9d5e984b5f to your computer and use it in GitHub Desktop.
Save converge/6ddfcf465fc9cf6ba40c7e9d5e984b5f to your computer and use it in GitHub Desktop.
// next step: every time there is a new log, call socket.emit('newLogData')
io.on('connection', function (socket) {
console.log('connected <-')
// @todo: windows version
var tail = spawn("tail", ["-f", filename]);
tail.stdout.on("data", function (data) {
console.log(data.toString('utf-8'))
socket.emit('newLogData', { newLog: data.toString('utf-8') } )
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment