Overview
runtime.js is an open-source library operating system for the cloud that runs JavaScript, could be bundled up with an application and deployed as a lightweight and immutable VM image.
It's built on V8 JavaScript engine and uses event-driven and non-blocking I/O model inspired by Node.js. At the moment KVM is the only supported hypervisor.
Example index.js:
var runtime = require('runtimejs')
console.log('Hello world!')
Let's bundle up and run it!
# install dependencies
npm install runtimejs
npm install runtimeify -g
npm install runtime-tools -g
# bundle up ramdisk image
runtimeify index.js -o initrd
# make sure you have QEMU installed
brew install qemu # OSX
sudo apt-get install qemu # Ubuntu
# run it in QEMU
runtime-qemu ./initrd
WARNING: project is in development and not ready for production use.
How does it work?
There are two main components: operating system (OS) kernel and a core JavaScript library.
The kernel is the C++ program that manages low-level resources like CPU and memory, runs applications using embedded V8 JavaScript engine, and exposes raw hardware to JavaScript.
Application, its dependencies and the core library are bundled up using Browserify, then packed into ramdisk image for kernel to use.
runtime.js is a library operating system, because application uses it as its own dependency (library). Internal architecture is similar to exokernels, where system exposes the hardware to application code and forces as few abstractions as possible.
Quick Start
The easiest way to start playing with runtime.js is to clone Hello World repository and run it in QEMU. First, make sure you have Node.js and QEMUinstalled.
Install Node.js
Install Node.js if you don't have it already installed. nodejs.org/download/. npmpackage manager will be also installed.
Install QEMU
Install using Homebrew on OSX:
brew install qemu
Install on Ubuntu:
sudo apt-get install qemu
Install on Windows:
QEMU binaries qemu.weilnetz.de/
set PATH=%PATH%;C:\Program Files\qemu
See also:
wiki.qemu.org/Download
en.wikibooks.org/wiki/QEMU/I…
Hello World repository
Clone and install dependencies:
git clone https://github.com/runtimejs/helloworld.git
cd helloworld
npm install
Run:
npm start
Developer tools
Tools could be included into application as dev-dependencies (as in Hello World example) or installed globally.
runtimeify
runtimeify creates code bundles and packages them into initrd (initial ramdisk) images. It's a wrapper around Browserify.
npm install runtimeify -g
runtime-tools
Adds runtime-qemu
command to be able to easily run bundled
up image in QEMU.
npm install runtime-tools -g
Creating an application
It's easy to create a new project and manage dependencies using npm package manager:
npm init
npm install runtimejs --save
npm install runtimeify --save-dev
npm install runtime-tools --save-dev
index.js
var runtime = require('runtimejs');
console.log('It works!');
Create bundle:
runtimeify index.js -o initrd
Run in QEMU locally:
runtime-qemu ./initrd
Next Steps
Check out GitHub repository. The project is in development and a lot of important features are missing. Contributions are welcome.