Skip to content

Instantly share code, notes, and snippets.

@jpbarbosa
Last active June 18, 2016 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpbarbosa/7ebb3807e2f65b3cd5f4a30d8733a5f7 to your computer and use it in GitHub Desktop.
Save jpbarbosa/7ebb3807e2f65b3cd5f4a30d8733a5f7 to your computer and use it in GitHub Desktop.
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