<commit_before>var util = require('util');
var spawn = require('child_process').spawn;
var WebSocketServer = require('websocket').server;

var filename = process.argv[2];
if (!filename)
	return util.puts("Usage: node server.js <LOG>");

http = require('http');
var server = http.createServer(function(req,res){
	res.writeHead(400);
	res.end();
});
server.listen(31216);

var ws = new WebSocketServer({
	httpServer: server,
	autoAcceptConnections: false
});

ws.on('request', function(req){
	var con = req.accept('cloogle-stats', req.origin);
	var tail = spawn("tail", ["-f", filename]);

	con.on('close', function(reason, desc){
		tail.kill();
	});
	
	tail.stdout.on('data', function(data){
		var match = /<-- (\{.*\})/.exec(data);
		if (match != null) {
			console.log(match[1]);
			con.sendUTF(match[1]);
		}
	});
});<commit_msg>Only get last result on startup stats<commit_after>var util = require('util');
var spawn = require('child_process').spawn;
var WebSocketServer = require('websocket').server;

var filename = process.argv[2];
if (!filename)
	return util.puts("Usage: node server.js <LOG>");

http = require('http');
var server = http.createServer(function(req,res){
	res.writeHead(400);
	res.end();
});
server.listen(31216);

var ws = new WebSocketServer({
	httpServer: server,
	autoAcceptConnections: false
});

ws.on('request', function(req){
	var con = req.accept('cloogle-stats', req.origin);
	var tail = spawn("tail", ["-n", "2", "-f", filename]);

	con.on('close', function(reason, desc){
		tail.kill();
	});
	
	tail.stdout.on('data', function(data){
		var match = /<-- (\{.*\})/.exec(data);
		if (match != null) {
			console.log(match[1]);
			con.sendUTF(match[1]);
		}
	});
});
{'fraction_non_alphanumeric': 0.21154979375368296, 'fraction_numerical': 0.013553329404832056, 'mean_word_length': 4.937062937062937, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2681993', 'n_tokens_mistral': 627, 'n_tokens_neox': 588, 'n_words': 128}