Add NodeBase function concept

This commit is contained in:
Alex Ellis
2017-04-06 13:19:09 +01:00
parent 8a53bacef2
commit 85a2fe8573
8 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,3 @@
FROM functions/nodebase:alpine-6.9.1
COPY handler.js .

View File

@ -0,0 +1,3 @@
#!/bin/bash
docker build -t functions/nodeinfo:func . -f Dockerfile.func

View File

@ -0,0 +1,23 @@
'use strict'
let os = require('os');
let fs = require('fs');
let util = require('util');
module.exports = (content, callback) => {
fs.readFile("/etc/hostname", "utf8", (err, data) => {
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";
}
callback(null, val);
});
};

View File

@ -1 +0,0 @@
docker build -t nodeinfo . ; docker service rm NodeInfo ; docker service create --network=functions --name NodeInfo nodeinfo