-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcrawler.js
More file actions
46 lines (42 loc) · 1.03 KB
/
crawler.js
File metadata and controls
46 lines (42 loc) · 1.03 KB
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 broadway = require('broadway');
var app = new broadway.App();
app.use(require('./plugins/main.js'));
app.use(require('./plugins/crawler.js'));
function crawlWhile(updates) {
if (updates) {
app.crawler.crawlBatch(function(updates) {crawlWhile(updates)});
}
else {
app.log("crawler.js", "waiting...");
setTimeout(function() {crawlWhile(true)}, 30000);
}
}
app.init(function(err) {
if (err) {
app.log(err);
}
else {
app.log("crawler.js", "started");
if (process.argv[2]) {
// Launch the crawl process for a single channel.
app.channel.findById(process.argv[2], function(err, channel) {
if (err) {
app.err(err);
}
else if (channel) {
app.crawler.crawl(channel, function() {
app.log("crawler.js", "channel crawl complete");
process.exit();
});
}
else {
app.err("crawler.js", "channel not found");
process.exit();
}
})
}
else {
crawlWhile(true);
}
}
});