Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const spawn = require('./node_modules/child-process-promise/lib').spawn;
- process.env["PATH"] = process.env["PATH"] + ":" +
- process.env["LAMBDA_TASK_ROOT"];
- function spawnCmd(cmd, args, opts) {
- var opts = opts||{};
- console.log("[spawn]", cmd, args.join(' '), opts);
- let cmd_promise = spawn(cmd, args, opts);
- let child = cmd_promise.childProcess;
- child.stdout.on('data', function(chunk) {
- console.log("[" + cmd + ":stdout] " + chunk);
- });
- child.stderr.on('data', function(chunk) {
- console.log("[" + cmd + ":stderr] " + chunk);
- });
- return cmd_promise;
- }
- exports.lambda_handler = function(event, context) {
- spawnCmd("uname", ["-a"], {
- cwd: '/tmp'
- }).then(function(result) {
- context.succeed(result);
- }, function(err) {
- context.fail(err);
- });
- };
Add Comment
Please, Sign In to add comment