Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Manoj Mali committed Dec 8, 2016
0 parents commit be24b72
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:argon

RUN mkdir /app
COPY package.json /app
WORKDIR /app
RUN npm install -g nodemon
RUN npm install --production
COPY . /app/
CMD ["npm", "start"]
78 changes: 78 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Created by manojmali1 on 06/10/16.
*/

var Consumer = require('sqs-consumer');
const request = require('request')
const AWS = require('aws-sdk')

const accessKeyId = 'frfre'
const secretAccessKey = 'wfwf'


//this is for testing and backward compatibility
AWS.config.update({
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey
})

var app = Consumer.create({
queueUrl: process.env['QUEUE_NAME'], //'http://192.168.10.196:4568/contentTest',
handleMessage: function (message, done) {
// do some work with `message`
console.log(message)
var url = process.env['REQUEST_URL']//'http://127.0.0.1:8000/content-engine/task/1.0/fetch-content'

request.post({
headers: {'content-type': 'text/plain'},
url:url, body: message.Body
}, function (err, data) {

console.log(err)

console.log(data)

})
done();
},
sqs: new AWS.SQS({
region: 'us-east-1',
apiVersion: '2012-11-05',
endpoint: process.env['SQS_ENDPOINT']//'http://192.168.10.196:4568'
})
});

app.on('error', function (err) {
console.log(err.message);
});

app.start()

//var app1 = Consumer.create({
// queueUrl: 'http://192.168.10.196:4568/scraperTest',
// handleMessage: function (message, done) {
// // do some work with `message`
// console.log(message)
// var url = 'http://127.0.0.1:5000/content-engine/task/1.0/scrape-links'
//
// request.post({
// headers: {'content-type': 'text/plain'},
// url:url, body: message.Body
// }, function (err, data) {
//
// })
// done();
// },
// sqs: new AWS.SQS({
// region: 'us-east-1',
// apiVersion: '2012-11-05',
// endpoint: 'http://192.168.10.196:4568'
// })
//});
//
//app1.on('error', function (err) {
// console.log(err.message);
//});
//
//app.start();
//app1.start();
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "sqs-worker",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node ./index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.6.6",
"lodash": "^4.17.2",
"request": "^2.75.0",
"sqs-consumer": "^3.3.0"
}
}

0 comments on commit be24b72

Please sign in to comment.