Last active
June 18, 2016 20:02
-
-
Save jpbarbosa/7ebb3807e2f65b3cd5f4a30d8733a5f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('child_process').exec; | |
exports.handler = function(event, context) { | |
cmd = "" + | |
"export CS_HOME=/var/task/cloud-search-tools/;" + | |
"export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.77-0.b03.9.amzn1.x86_64/jre;" + | |
"curl -s -o /tmp/input.file " + event.url + ";" + | |
"cloud-search-tools/bin/cs-import-documents --source /tmp/input.file --output /tmp > /dev/null;" + | |
"cat /tmp/1.json"; | |
child = exec(cmd, function(error, stdout, stderr) { | |
// Resolve with result of process | |
context.done(error, JSON.parse(stdout)); | |
}); | |
// Log process stdout and stderr | |
child.stdout.on('data', console.log); | |
child.stderr.on('data', console.error); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment