-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (36 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var bodyParser = require('body-parser');
var Tail = require('always-tail');
var fs = require('fs');
var filename = "../processing-engine/nlu.log";
io.on('connection', function (socket) {
console.log('a user connected');
});
if (!fs.existsSync(filename)) fs.writeFileSync(filename, "");
var tail = new Tail(filename, '\n');
tail.on('line', function (data) {
console.log("got line:", data);
io.emit("VALUE", data);
});
tail.on('error', function (data) {
console.log("error:", data);
});
tail.watch();
// ############# OVERALL ################### //
var overallname = "../overall.log";
if (!fs.existsSync(overallname)) fs.writeFileSync(overallname, "");
var overallTail = new Tail(overallname, '\n');
overallTail.on('line', function (data) {
console.log("emitting", data);
io.emit("OVERALL", data);
});
overallTail.on('error', function (data) {
console.log("error:", data);
});
overallTail.watch();
// ############# OVERALL END ################### //
http.listen(3000, function () {
console.log('listening on *:3000');
});