-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (39 loc) · 1.13 KB
/
app.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
var express = require('express');
var routes = require('./routes/index');
var path = require('path');
var favicon = require('serve-favicon');
var app = express();
app.set('views', __dirname + '/template');
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, 'public')));
var myDat = [];
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use('/', routes);
setInterval(function () {
var fork = require('child_process').fork;
var cp = fork('./parser');
cp.on('message', function (msgobj) {
myDat = msgobj;
console.log(msgobj);
require('./CreateDB');
});
cp.send({
text: 'I send msg'
});
}, 120000);
function getPages(callback) {
callback(myDat);
}
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {body: '<b>Извините. Произошла ошибка.</b>',
error: err.status, message: err.message
});
});
module.exports = app;
module.exports.getPages = getPages;