<commit_before>'use strict';

var http = require('http'),
    ws = require('ws'),
    connect = require('connect'),
    serveStatic = require('serve-static'),
    Tail = require('tail').Tail;

var wss, name, app, server;

app = connect();
app.use(serveStatic('./public', {'index': ['index.html', 'index.htm']}));
server = http.createServer(app).listen(8080);

name = 'log.txt';

wss = new ws.Server({server: server});

wss.on('connection', function (ws) {
    var tail; // readStream

    ws.on('message', function (message) {
        console.log('received: %s', message);
    });

    tail = new Tail(name);
    tail.on('line', function (data) {
        console.log(data);
        ws.send(data);
    });

    tail.on('error', function (err) {
        console.log('ERROR: ', err);
    });
});<commit_msg>unwatch tail after closing session<commit_after>'use strict';

var http = require('http'),
    ws = require('ws'),
    connect = require('connect'),
    serveStatic = require('serve-static'),
    Tail = require('tail').Tail;

var wss, name, app, server;

app = connect();
app.use(serveStatic('./public', {'index': ['index.html', 'index.htm']}));
server = http.createServer(app).listen(8080);

name = 'log.txt';

wss = new ws.Server({server: server});

wss.on('connection', function (ws) {
    var tail; // readStream

    ws.on('message', function (message) {
        console.log('received: %s', message);
    });

    tail = new Tail(name);
    tail.on('line', function (data) {
        console.log(data);
        ws.send(data);
    });

    tail.on('error', function (err) {
        console.log('ERROR: ', err);
    });

    ws.on('close', function () {
        tail.unwatch();
        console.log('disconnected');
    });
});
{'fraction_non_alphanumeric': 0.2061200923787529, 'fraction_numerical': 0.004618937644341801, 'mean_word_length': 3.2063106796116503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2420593', 'n_tokens_mistral': 584, 'n_tokens_neox': 557, 'n_words': 122}