From da0c020b4984229763b6ab873bdf84545fed0036 Mon Sep 17 00:00:00 2001 From: Serge Date: Sun, 14 Jun 2015 23:05:49 +0300 Subject: [PATCH 1/5] Add description into title --- _includes/head.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/head.html b/_includes/head.html index 557e4cc..62a143b 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -3,7 +3,7 @@ - {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %} + {% if page.title %}{{ page.title }}{% else %}{{ site.title }} – {{ site.description }}{% endif %} From 53d990016882837638becd394019bf601da0d2b6 Mon Sep 17 00:00:00 2001 From: Serge Date: Mon, 29 Jun 2015 23:53:04 +0300 Subject: [PATCH 2/5] Minor improvements --- _includes/subheader.html | 7 +++++++ _layouts/defaultPage.html | 22 ++++++++++++++++++++++ _layouts/page.html | 10 +++++----- _sass/_base.scss | 2 +- _sass/_layout.scss | 10 ++++++++-- getting-started.md | 4 ++-- index.md | 2 +- 7 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 _includes/subheader.html create mode 100644 _layouts/defaultPage.html diff --git a/_includes/subheader.html b/_includes/subheader.html new file mode 100644 index 0000000..c3d5021 --- /dev/null +++ b/_includes/subheader.html @@ -0,0 +1,7 @@ +
+
+
+ {{ page.title }} +
+
+
diff --git a/_layouts/defaultPage.html b/_layouts/defaultPage.html new file mode 100644 index 0000000..d641b8b --- /dev/null +++ b/_layouts/defaultPage.html @@ -0,0 +1,22 @@ + + + + {% include head.html %} + + + + {% include header.html %} + + {% include subheader.html %} + +
+
+ {{ content }} +
+
+ + {% include footer.html %} + + + + diff --git a/_layouts/page.html b/_layouts/page.html index 23191ef..8dcf8e5 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -1,17 +1,17 @@ --- -layout: default +layout: defaultPage ---
-
+ diff --git a/_sass/_base.scss b/_sass/_base.scss index 1e46f8e..74108f6 100644 --- a/_sass/_base.scss +++ b/_sass/_base.scss @@ -163,6 +163,11 @@ pre { padding-left: $spacing-unit; @extend %clearfix; + .homepage & { + max-width: -webkit-calc(#{$home-content-width} - (#{$spacing-unit} * 2)); + max-width: calc(#{$home-content-width} - (#{$spacing-unit} * 2)); + } + @include media-query($on-laptop) { max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit})); max-width: calc(#{$content-width} - (#{$spacing-unit})); @@ -217,3 +222,9 @@ pre { .button:visited, .button:hover, .button:focus { color: #fafafa; } + +table, table th, table td { + border: 1px solid #e8e8e8; + border-collapse: collapse; + padding: 10px; +} diff --git a/_sass/_layout.scss b/_sass/_layout.scss index 0b1028d..33eb7dd 100644 --- a/_sass/_layout.scss +++ b/_sass/_layout.scss @@ -271,9 +271,12 @@ $BigTitleColor: #8EB290; } } +.post-sidebar { + margin-left: 200px; +} + .post-content { margin-bottom: $spacing-unit; - margin-left: 200px; @include media-query($on-palm) { margin-left: 0px; diff --git a/api-docs.md b/api-docs.md new file mode 100644 index 0000000..b49457e --- /dev/null +++ b/api-docs.md @@ -0,0 +1,99 @@ +--- +layout: page +permalink: /api-docs/ +--- + + +## net.TCPSocket + +Provides raw TCP protocol connection socket. + + +constructor() +=== + +Create new socket object in the closed state. + +```js +const socket = new runtime.net.TCPSocket(); +``` + +open(string ip, number port) +=== + +Open socket and connect to TCP server using `ip` address and `port`. + +Argument | Type | Description +--- | --- | --- +ip | string | Server IP address to connect to. +port | number | TCP server port. +-- + +```js +socket.open('127.0.0.1', 8080); +``` + +send(Uint8Array buffer) +=== + +Push data buffer into socket transmit queue. This does not copy data, buffer will be sent directly to network interface, data modifications made after `send()` call may affect transmitted data. + +Argument | Type | Description +--- | --- | --- +buffer | Uint8Array | Buffer to send. +return | bool | Hint to the caller that transmit queue is full. +-- + +```js +socket.send(new Uint8Array([1, 2, 3])); +``` + +halfclose() +=== + +Send stream ended notification, but keep receiving new data. + +```js +socket.halfclose(); +``` + +close() +=== + +Close the socket, stop transmitting and receiving new data. + +```js +socket.close(); +``` + +ondata +=== + +Handler for received data events. + +```js +socket.ondata = function(buffer) { + console.log(buffer); +}; +``` + +Example +========== + +```js +var socket = new runtime.net.TCPSocket(); + +socket.onopen = function() { + socket.send(new Uint8Array([1, 2, 3])); +}; + +socket.ondata = function(buf) { +}; + +socket.onend = function() { +}; + +socket.open('127.0.0.1', 8080); +``` + + diff --git a/blog.html b/blog.html index 94a1865..1f0798d 100644 --- a/blog.html +++ b/blog.html @@ -1,5 +1,5 @@ --- -layout: index +layout: blog --- diff --git a/css/main.scss b/css/main.scss index 27226b6..ec78f30 100755 --- a/css/main.scss +++ b/css/main.scss @@ -26,6 +26,7 @@ $grey-color-dark: darken($grey-color, 25%); // Width of the content area $content-width: 900px; +$home-content-width: 760px; $on-palm: 600px; $on-laptop: 800px; diff --git a/getting-started.md b/getting-started.md index c22d647..b964dc7 100644 --- a/getting-started.md +++ b/getting-started.md @@ -13,7 +13,7 @@ First, make sure you have [Node.js](https://nodejs.org/download/) and [QEMU](htt Install Node.js if you don't have it already installed. [https://nodejs.org/download/](https://nodejs.org/download/). -[npm](https://www.npmjs.com/) package manager will be also installed. +[npm](https://www.npmjs.com/) package manager will also be installed. #### Install QEMU @@ -42,6 +42,14 @@ See also: [http://wiki.qemu.org/Download](http://wiki.qemu.org/Download)
[http://en.wikibooks.org/wiki/QEMU/Installing_QEMU](http://en.wikibooks.org/wiki/QEMU/Installing_QEMU) +#### Install runtime.js command line tools + +``` +npm install runtime-cli -g +``` + +This adds global `runtime` command for easy access. + #### Hello World repository Clone and install dependencies: @@ -58,54 +66,27 @@ Run: npm start ``` -## Developer tools - -Tools could be included into application as dev-dependencies (as in Hello World example) or installed globally. - -#### runtimeify - -[runtimeify](https://www.npmjs.com/package/runtimeify) creates code bundles and packages them into initrd (initial ramdisk) images. It's a wrapper around [Browserify](http://browserify.org/). - -```bash -npm install runtimeify -g -``` - -#### runtime-tools - -Adds `runtime-qemu` command to be able to easily run bundled up image in QEMU. - -```bash -npm install runtime-tools -g -``` +Done, project should load and print "Hello World!". -## Creating an application +## New application It's easy to create a new project and manage dependencies using npm package manager: ```bash npm init npm install runtimejs --save -npm install runtimeify --save-dev -npm install runtime-tools --save-dev ``` index.js ```js -var runtime = require('runtimejs'); console.log('It works!'); ``` -Create bundle: - -```bash -runtimeify index.js -o initrd -``` - -Run in QEMU locally: +Run in QEMU: ```bash -runtime-qemu ./initrd +runtime start ``` #### Next Steps diff --git a/index.md b/index.md index a4d00bd..0952ecb 100644 --- a/index.md +++ b/index.md @@ -4,46 +4,51 @@ layout: index ## 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. +**runtime.js** is an open-source library operating system (unikernel) for the cloud that runs JavaScript, can be bundled up with an application and deployed as a lightweight and immutable VM image. It's built on [V8 JavaScript engine](https://code.google.com/p/v8/) and uses event-driven and non-blocking I/O model inspired by Node.js. At the moment [KVM](http://www.linux-kvm.org/page/Main_Page) is the only supported hypervisor. -Example **index.js**: +It tries to be compatible with npm module ecosystem and supports some of the Node.js API. -```js -var runtime = require('runtimejs') -console.log('Hello world!') -``` +_WARNING: project is in development and not ready for production use._ + +## Usage -Let's bundle up and run it! +Install command line tool `runtime-cli`, it will add `runtime` command to the shell: -```bash -# install dependencies -npm install runtimejs -npm install runtimeify -g -npm install runtime-tools -g +``` +npm install runtime-cli -g +``` -# bundle up ramdisk image -runtimeify index.js -o initrd +Make sure QEMU is installed, it enables running applications locally: -# make sure you have QEMU installed +``` brew install qemu # OSX sudo apt-get install qemu # Ubuntu +``` -# run it in QEMU -runtime-qemu ./initrd +Setup simple project using npm: + +``` +mkdir project +cd project +npm init +npm install runtimejs --save +echo "console.log('ok')" > index.js ``` -WARNING: project is in development and not ready for production use. +Run project locally in QEMU: -## How does it work? +``` +runtime start +``` -There are two main components: operating system (OS) kernel and a core JavaScript library. +That's it, QEMU should load and print `ok` to console. -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. +## How does it work? -Application, its dependencies and the core library are bundled up using Browserify, then packed into ramdisk image for kernel to use. +There are two main components: operating system kernel and a JavaScript library. -runtime.js is a library operating system, because application uses it as its own dependency (library). Internal architecture is similar to [exokernels](https://en.wikipedia.org/wiki/Exokernel), where system exposes the hardware to application code and forces as few abstractions as possible. +The kernel is written in C++ and manages low-level resources like CPU and memory, runs JavaScript using embedded V8 engine. Library drives the entire system and manages hardware devices (usually virtualized by hypervisor). Get Started ≫