These are chat archives for mentum/lambdaws

31st
Mar 2015
zulutune
@zulutune
Mar 31 2015 22:14

Hey guys,
When I start a new process with require('child_process').spawn I always get "Spawn EACCES".
And when I use require('child_process').execFile, I get "Process exited before completing request".
According to the lambda docs, lambda supports creating processes, and have seen lots of examples doing that. I can't figure out what I am doing wrong. Have a stripped down, simple version which doesn't work either:

var path = require('path'),
      childProcess = require('child_process')
      , fs = require('fs');

exports.handler = function(event, context) {
  console.log('starting handler', event);

  var nodePath = path.join(__dirname, 'node');
  var nodeArgs = [path.join(__dirname, 'hello.js')];

  console.log('calling node: ', nodePath, nodeArgs);

  try {
    var proc = childProcess.spawn(nodePath, nodeArgs);

    proc.stdout.on('data', function (data) {
      console.log(data.toString('utf8'));
    });

    proc.stderr.on('data', function (data) {
      console.log('error  ---:> ' + data);
    });

    proc.on('exit', function (code) {
      console.log('child process exited with code ' + code);
      context.done();
    });

  } catch (e) {
    console.log(e);
    context.done(e, null);
  }


};

Anyone ideas?

I'm using node just as an example here, and it also doesn't work with other binaries.
The file is an executable: "-rwxr-xr-x@ 1 zulutune staff 20231104 Mar 24 03:08 node"