Skip to content
Snippets Groups Projects
Commit 8d0996ad authored by Alex Ellis (OpenFaaS Ltd)'s avatar Alex Ellis (OpenFaaS Ltd)
Browse files

Add nodeinfo-http - a faster nodeinfo

parent e2494e22
No related branches found
No related tags found
No related merge requests found
template
build
'use strict'
let os = require('os');
let fs = require('fs');
const fsPromises = fs.promises
let util = require('util');
module.exports = async (event, context) => {
let content = event.body;
let res = await info(content)
return context
.status(200)
.succeed(res)
}
async function info(content, callback) {
let data = await fsPromises.readFile("/etc/hostname", "utf8")
let val = "";
val += "Hostname: " + data +"\n";
val += "Platform: " + os.platform()+"\n";
val += "Arch: " + os.arch() + "\n";
val += "CPU count: " + os.cpus().length+ "\n";
val += "Uptime: " + os.uptime()+ "\n";
if (content && content.length && content.indexOf("verbose") > -1) {
val += util.inspect(os.cpus()) + "\n";
val += util.inspect(os.networkInterfaces())+ "\n"
}
return val
};
{
"name": "openfaas-function",
"version": "1.0.0",
"description": "OpenFaaS Function",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 0"
},
"keywords": [],
"author": "OpenFaaS Ltd",
"license": "MIT"
}
...@@ -90,3 +90,11 @@ functions: ...@@ -90,3 +90,11 @@ functions:
lang: go lang: go
handler: ./business-strategy-generator handler: ./business-strategy-generator
image: functions/business-strategy-generator:0.13.0 image: functions/business-strategy-generator:0.13.0
nodeinfo-http:
lang: node12
handler: ./nodeinfo-http
image: functions/nodeinfo-http:latest
environment:
RAW_BODY: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment