Skip to content

Instantly share code, notes, and snippets.

@apstndb
Last active June 13, 2018 03:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apstndb/188193babd51aa6d9ee9b412b4e57c0f to your computer and use it in GitHub Desktop.
Save apstndb/188193babd51aa6d9ee9b412b4e57c0f to your computer and use it in GitHub Desktop.
App Engine Standard Node.js Runtime uses gVisor.
'use strict';
// [START app]
const express = require('express');
const bodyParser = require('body-parser');
const child_process = require('child_process');;
const fs = require('fs');
const app = express();
app.use(bodyParser.json()); // for parsing application/json
app.post('/exec', (req, res) => {
child_process.execFile(req.body.file, req.body.args, function(err, stdout, stderr){
res.status(200).send(stdout).end();
});
});
app.post('/read', (req, res) => {
fs.readFile(req.body.file, function(err, data){
res.status(200).send(data);
});
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
// [END app]
runtime: nodejs8
service: nodejs8

It can be checked by the same method of Google Cloud Functions

deploy GAE/SE Node.js

$ gcloud app deploy --quiet app.yaml

check files

$ curl "https://nodejs8-dot-${PROJECT_NAME}.appspot.com/read" -H 'Content-Type:application/json' -d '{"file": "/proc/filesystems"}'                                                                                                  
nodev   9p
nodev   devtmpfs
nodev   proc
nodev   ramdiskfs
nodev   sysfs
nodev   tmpfs

$ curl "https://nodejs8-dot-${PROJECT_NAME}.appspot.com/read" -H 'Content-Type:application/json' -d '{"file": "/proc/stat"}' 
cpu  0 0 0 0 0 0 0 0 0 0
cpu0 0 0 0 0 0 0 0 0 0 0
cpu1 0 0 0 0 0 0 0 0 0 0
cpu2 0 0 0 0 0 0 0 0 0 0
cpu3 0 0 0 0 0 0 0 0 0 0
cpu4 0 0 0 0 0 0 0 0 0 0
cpu5 0 0 0 0 0 0 0 0 0 0
cpu6 0 0 0 0 0 0 0 0 0 0
cpu7 0 0 0 0 0 0 0 0 0 0
intr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 0
btime 1528852185
processes 0
procs_running 0
procs_blocked 0
softirq 0 0 0 0 0 0 0 0 0 0 0

They are the same output with the gVisor document(/proc/filesystem, /proc/stat).

check easter egg

$ curl "https://nodejs8-dot-${PROJECT_NAME}.appspot.com/exec" -H 'Content-Type:application/json' -d '{"file": "/bin/dmesg"}'            
[    0.410051] Creating cloned children...
[    0.861788] Checking naughty and nice process list...
[    1.291077] Forking spaghetti code...
[    1.582258] Synthesizing system calls...
[    1.862408] Consulting tar man page...
[    1.992003] Letting the watchdogs out...
[    2.205865] Gathering forks...
[    2.364687] Searching for needles in stacks...
[    2.859057] Reading process obituaries...
[    2.943188] Constructing home...
[    3.150001] Ready!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment