Skip to content

AVENTER-UG/vmm-agent

Repository files navigation

Agent for MicroVM's

This is a fork of: https://github.com/codebench-dev/agent

Build

Build Rootfs and Kernel

make rootfs

Start MicroVM

make start-vm

Stop MicroVM

make stop-vm

Healthcheck

» curl -i 127.0.0.1:8080/health
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Date: Sat, 31 Jul 2021 20:02:45 GMT
Content-Length: 2

Shutdown

» curl -i 127.0.0.1:8080/shutdown

Compile and run standalone code

C

» curl -i localhost:8080/run -X POST --data '{"code":"#include <stdio.h>\r\nint main() {\r\n   printf(\"Hello, C!\");\r\n   return 0;\r\n}","id":"123","variant":"gcc","language":"c"}' -H 'Content-Type: application/json'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 31 Jul 2021 20:04:04 GMT
Content-Length: 104

{"message":"Success","error":"","stdout":"Hello, C!","stderr":"","exec_duration":1843,"mem_usage":9432}

C++

» curl -i -H 'Content-Type: application/json' -X POST http://localhost:8080/run --data '{"id":"1235","code":"#include <iostream>\n\nint main() {\n    std::cout << \"Hello, C++!\";\n    return 0;\n}\n","language":"cpp", "variant":"cpp"}'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 31 Jul 2021 20:04:50 GMT
Content-Length: 106

{"message":"Success","error":"","stdout":"Hello, C++!","stderr":"","exec_duration":3899,"mem_usage":9972}

Python

» curl -i -H 'Content-Type: application/json' -X POST http://localhost:8080/run --data '{"id":"1234","code":"print(\"Hello, Python!\")","language":"python", "variant":"cpython3"}'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 31 Jul 2021 20:06:31 GMT
Content-Length: 113

{"message":"Success","error":"","stdout":"Hello, Python!\n","stderr":"","exec_duration":20958,"mem_usage":10620}

Go

» curl -i localhost:8080/run -X POST --data '{"code":"package main\r\n\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n    fmt.Println(\"Hello, Go!\")\r\n}","id":"123","variant":"go","language":"go"}' -H 'Content-Type: application/json'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 31 Jul 2021 20:07:14 GMT
Content-Length: 108

{"message":"Success","error":"","stdout":"Hello, Go!\n","stderr":"","exec_duration":4706,"mem_usage":10620}

Wasm

» curl -i localhost:8080/run -X POST -F file=@main.wasm -F id=1234 -F language=wasm -F variant=wasm
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 31 Jul 2021 20:07:14 GMT
Content-Length: 108

{"message":"Success","error":"","stdout":"Hello, Go!\n","stderr":"","exec_duration":4706,"mem_usage":10620}

Bash

» curl -i localhost:8080/run -X POST --data '{"code":"echo test","id":"123","variant":"bash","language":"bash"}' -H 'Content-Type: application/json'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 31 Jul 2021 20:07:14 GMT
Content-Length: 108

{"message":"Success","error":"","stdout":"Hello, Go!\n","stderr":"","exec_duration":4706,"mem_usage":10620}