-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrawl.js
40 lines (32 loc) · 967 Bytes
/
crawl.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
var ini = require('ini');
var fs = require('graceful-fs');
var Log = require('log');
var arguments = require(__dirname + '/lib/arguments.js');
global.log = new Log(
'debug',
fs.createWriteStream(__dirname + '/crawler.log', {
flags: 'a',
encoding: null,
mode: 0666
})
);
global.parameters = ini.parse(
fs.readFileSync(__dirname + '/config/parameters.ini', 'utf-8')
).parameters;
global.filmError = {};
process.on('uncaughtException', (err) => {
console.error('Uncaught Exception:', err);
});
arguments.getAction(function (action, argument) {
var crawler = require(__dirname + '/lib/actions/' + action + '.js');
process.on('uncaughtException', function (err) {
// console.log('UNCAUGHT EXCEPTION - keeping process alive:', err);
});
if (action === 'user_friends' || action === 'id') {
crawler.start(argument);
} else if (action === 'new_platform') {
crawler.start(argument);
} else {
crawler.start();
}
});