Skip to content

Commit

Permalink
Merge branch 'dl/docker-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
di3goleite committed Jun 1, 2018
2 parents a2047f8 + 1e79280 commit 8e11483
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ function crawlFeed(URL, callback) {

request(URL)
.on('error', function (error) {
// console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
callback(error);
})
.on('response', function () {
this.pipe(feedparser);

feedparser.on('error', function (error) {
// console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
});

feedparser.on('readable', function () {
Expand All @@ -34,7 +34,7 @@ function fetchLatestPosts() {

Feed.find({}, function (error, feeds) {
if (error) {
// console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
} else {
const Queue = require('bee-queue');
const queue = new Queue(process.env.CRAWL_QUEUE, {
Expand All @@ -47,7 +47,7 @@ function fetchLatestPosts() {
queue.createJob(feed).save();
});

// console.log('\x1b[34m[INFO]\x1b[0m', `${feeds.length} feeds to crawl`);
console.log('\x1b[34m[INFO]\x1b[0m', `${feeds.length} feeds to crawl`);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function load(RSSFile, callback) {

fs.readFile(RSSFile, function (error, data) {
if (error) {
// console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
console.log('\x1b[31m[ERROR]\x1b[0m', error.message);
callback(error);
} else {
const xml2js = require('xml2js');
Expand All @@ -22,9 +22,9 @@ function load(RSSFile, callback) {
const Feed = require('../models/feed');
Feed.insertMany(feeds, { ordered: false }, function (error) {
if (error) {
// console.log('\x1b[34m[INFO]\x1b[0m', `${feeds.length} feeds found, ${feeds.length - error.writeErrors.length} inserted`);
console.log('\x1b[34m[INFO]\x1b[0m', `${feeds.length} feeds found, ${feeds.length - error.writeErrors.length} inserted`);
} else {
// console.log('\x1b[32m[SUCCESS]\x1b[0m', `${feeds.length} feeds inserted`);
console.log('\x1b[32m[SUCCESS]\x1b[0m', `${feeds.length} feeds inserted`);
}
callback(null);
});
Expand Down
12 changes: 6 additions & 6 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ queue.on('succeeded', (task, result) => {

Post.insertMany(posts, {ordered: false}, function(error) {
if (error) {
// console.log('\x1b[34m[INFO]\x1b[0m', `${posts.length} posts found`);
console.log('\x1b[34m[INFO]\x1b[0m', `${posts.length} posts found`);
} else {
// console.log('\x1b[32m[SUCCESS]\x1b[0m', `${posts.length} posts inserted`);
console.log('\x1b[32m[SUCCESS]\x1b[0m', `${posts.length} posts inserted`);
}
});
});

queue.on('retrying', (task, error) => {
// console.log(`Job ${task.id} failed with error ${error.message} but is being retried!`);
console.log(`Job ${task.id} failed with error ${error.message} but is being retried!`);
});

queue.on('error', (error) => {
// console.log(`A queue error happened: ${error.message}`);
console.log(`A queue error happened: ${error.message}`);
});

queue.on('failed', (task, error) => {
// console.log(`Job ${task.id} failed with error ${error.message}`);
console.log(`Job ${task.id} failed with error ${error.message}`);
});

queue.on('stalled', (taskId) => {
// console.log(`Job ${taskId} stalled and will be reprocessed`);
console.log(`Job ${taskId} stalled and will be reprocessed`);
});

0 comments on commit 8e11483

Please sign in to comment.