-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.js
executable file
·26 lines (23 loc) · 937 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
const spawnSync = require('child_process').spawnSync;
exports.handler = (event, context, callback) => {
// Invoke the executable via the provided ld-linux.so – this will
// force the right GLIBC version and its dependencies
const options = { input:JSON.stringify(event) };
const command = 'libraries/ld-linux-x86-64.so.2';
const childObject = spawnSync(command, ["--library-path", "libraries", "./Lambda"], options)
if (childObject.error) {
callback(childObject.error, null);
} else {
try {
// The executable's raw stdout is the Lambda output
var stdout = childObject.stdout.toString('utf8');
var stderr = childObject.stderr.toString('utf8');
var response = JSON.parse(stdout);
callback(null, response);
} catch(e) {
e.message += ": " + stderr
callback(e, null);
}
}
};