-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (26 loc) · 979 Bytes
/
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
var os = require("os");
var path = require('path')
var config = require('config');
var schedule = require('node-schedule');
var tako = require('tako');
var moment = require('moment');
var scrape = require('./lib/scrape');
// Schedule background tasks
var rule = new schedule.RecurrenceRule();
rule.minute = config.scrapeMinute;
var s = schedule.scheduleJob(rule, function(){
console.log(moment().format(), 'Launching scraper');
scrape.scrape(function() {
console.log(moment().format(), 'Finishing scraper');
});
});
// Create config for frontend and serve frontend files
app = tako();
app.route('/config.json').json({
cartoUser: config.cartoUser,
cartoTable: config.cartoTable,
});
app.route('/').file(path.join(__dirname, 'frontend/index.html'));
app.route('/frontend/*').files(path.join(__dirname, 'frontend'));
app.httpServer.listen(config.httpPort);
console.log(moment().format(), 'Running on ' + os.hostname() + ':'+ config.httpPort);