【发布时间】:2018-05-02 13:28:41
【问题描述】:
错误:生成 php-7-bin/bin/php ENOENT
process.env['PATH'] = process.env['PATH'] + ':' +
process.env['LAMBDA_TASK_ROOT'];
const spawn = require('child_process').spawn;
exports.handler = function(event, context) {
var php = spawn('php-7-bin/bin/php',['helloLambda.php']);
var output = "";
//send the input event json as string via STDIN to php process
php.stdin.write(JSON.stringify(event));
//close the php stream to unblock php process
php.stdin.end();
//dynamically collect php output
php.stdout.on('data', function(data) {console.log("data",data);
output+=data;
});
//react to potential errors
php.stderr.on('data', function(data) {
console.log("STDERR: "+data);
});
//finalize when php process is done.
php.on('close', function(code) {
context.succeed(JSON.parse(output));
});
}
我尝试给出这些可能的路径:
'php-7-bin/bin/php' (as in doc)<br>
'./php-7-bin/bin/php'<br>
'~/php-7-bin/bin/php'<br>
'/php-7-bin/bin/php'<br>
'php'
这是我关注的文档: https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/
【问题讨论】:
标签: php aws-lambda