Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/LiveUpdate/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"net" : [
["10.0.0.42", "255.255.255.0", "10.0.0.1"]
{
"iface": 0,
"config": "dhcp-with-fallback",
"address": "10.0.0.42",
"netmask": "255.255.255.0",
"gateway": "10.0.0.1"
}
]
}
7 changes: 2 additions & 5 deletions examples/STREAM/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
### STREAM: Sustainable Memory Bandwidth in High Performance Computers

Using Qemu and the IncludeOS boot program:
```
mkdir build
cd build
cmake ..
make
../run.sh stream_example
boot .
```

Output should show estimated memory bandwidth inside virtual machine.
2 changes: 1 addition & 1 deletion examples/STREAM/vm.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mem" : 1024
"mem" : 256
}
11 changes: 11 additions & 0 deletions examples/acorn/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"net" : [
{
"iface": 0,
"config": "dhcp-with-fallback",
"address": "10.0.0.42",
"netmask": "255.255.255.0",
"gateway": "10.0.0.1"
}
]
}
49 changes: 19 additions & 30 deletions examples/acorn/disk1/public/app/js/services/cpusage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
angular.module('acornWebApp')
.factory('CPUsage', function() {
// CPU usage chart
var date = new Date();
var total_data = ['total'];
var time_data = ['x', new Date()];
var idle_data = ['idle'];
var active_data = ['active'];
var time_data = ['x', date];

var cpu_usage_chart = {};

Expand All @@ -21,17 +20,19 @@ angular.module('acornWebApp')
x: 'x',
columns: [
time_data,
total_data,
idle_data,
active_data
],
colors: {
total: '#3A8BF1',
idle: '#3A8BF1',
active: '#F87E0C'
},
types: {
total: 'area-spline',
active: 'area-spline'
// 'line', 'spline', 'step', 'area', 'area-step' are also available to stack
idle: 'area',
active: 'area'
},
area : {
zerobased: true
}
},
axis: {
Expand All @@ -50,12 +51,12 @@ angular.module('acornWebApp')
},
y: {
label: {
text: 'cycles',
text: 'percent',
position: 'outer-middle'
},
tick: {
format: function (d) {
return d + " mill.";
return d + " %";
}
}
}
Expand All @@ -68,35 +69,23 @@ angular.module('acornWebApp')
};

CPUsage.prototype.update = function(usage) {
// Showing interval in number of seconds
var interval = usage.interval / 1000000;

if(total_data.length > 20) {
if(idle_data.length > 20) {
// Remove second element in each array (first element is name)
total_data.splice(1, 1);
active_data.splice(1, 1);
time_data.splice(1, 1);
idle_data.splice(1, 1);
active_data.splice(1, 1);
}

var total = usage.total;
var halt = usage.halt;
var active = total - halt;

// Showing cycles in millions
total /= 1000000;
active /= 1000000;

var d = new Date();

total_data.push(total.toFixed(3));
active_data.push(active.toFixed(3));
time_data.push(d);
time_data.push(new Date());
idle_data.push(usage.idle.toFixed(3));
active_data.push(usage.active.toFixed(3));

cpu_usage_chart.axis.labels({x: 'CPU data updated at an interval of ' + interval + ((interval > 1) ? ' seconds' : ' second')});
cpu_usage_chart.axis.labels({x: 'CPU usage over time'});
cpu_usage_chart.load({
columns: [
time_data,
total_data,
idle_data,
active_data
]
});
Expand Down
43 changes: 19 additions & 24 deletions examples/acorn/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Disk_ptr disk;
#include <isotime>
#include <net/inet4>

void Service::start()
static void start_acorn(net::Inet<net::IP4>& inet)
{
/** SETUP LOGGER */
const int LOGBUFFER_LEN = 1024*16;
Expand All @@ -45,7 +45,8 @@ void Service::start()
logger_->flush();
logger_->log("LUL\n");

OS::add_stdout([] (const char* data, size_t len) {
OS::add_stdout(
[] (const char* data, size_t len) {
// append timestamp
auto entry = "[" + isotime::now() + "]" + std::string{data, len};
logger_->log(entry);
Expand All @@ -55,28 +56,10 @@ void Service::start()

// init the first legit partition/filesystem
disk->init_fs(
[] (fs::error_t err, auto& fs)
[&inet] (fs::error_t err, auto& fs)
{
if (err) panic("Could not mount filesystem...\n");

/** IP STACK SETUP **/
// Bring up IPv4 stack on network interface 0
auto& stack = net::Inet4::ifconfig(5.0,
[] (bool timeout) {
printf("DHCP resolution %s\n", timeout ? "failed" : "succeeded");
if (timeout)
{
/**
* Default Manual config. Can only be done after timeout to work
* with DHCP offers going to unicast IP (e.g. in GCE)
**/
net::Inet4::stack().network_config({ 10,0,0,42 }, // IP
{ 255,255,255,0 }, // Netmask
{ 10,0,0,1 }, // Gateway
{ 8,8,8,8 }); // DNS
}
});

// only works with synchronous disks (memdisk)
list_static_content(disk);

Expand Down Expand Up @@ -125,8 +108,8 @@ void Service::start()
dashboard_->add(dashboard::Status::instance());
// Construct component
dashboard_->construct<dashboard::Statman>(Statman::get());
dashboard_->construct<dashboard::TCP>(stack.tcp());
dashboard_->construct<dashboard::CPUsage>(500ms);
dashboard_->construct<dashboard::TCP>(inet.tcp());
dashboard_->construct<dashboard::CPUsage>();
dashboard_->construct<dashboard::Logger>(*logger_, static_cast<size_t>(50));

// Add Dashboard routes to "/api/dashboard"
Expand Down Expand Up @@ -154,7 +137,7 @@ void Service::start()


/** SERVER SETUP **/
server_ = std::make_unique<Server>(stack.tcp());
server_ = std::make_unique<Server>(inet.tcp());
// set routes and start listening
server_->set_routes(router).listen(80);

Expand All @@ -178,3 +161,15 @@ void Service::start()
}); // < disk

}

void Service::start()
{
auto& inet = net::Super_stack::get<net::IP4>(0);
if (not inet.is_configured())
{
inet.on_config(start_acorn);
}
else {
start_acorn(inet);
}
}
14 changes: 1 addition & 13 deletions examples/demo_service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
set(ENV{INCLUDEOS_PREFIX} /usr/local)
endif()
include($ENV{INCLUDEOS_PREFIX}/includeos/pre.service.cmake)

project (demo_service)

# Human-readable name of your service
Expand All @@ -19,19 +18,9 @@ set(SOURCES
service.cpp # ...add more here
)

#
# Service CMake options
# (uncomment to enable)
#

# MISC:

# To add your own include paths:
# set(LOCAL_INCLUDES ".")

# Adding memdisk (expects my.disk to exist in current dir):
# set(MEMDISK ${CMAKE_SOURCE_DIR}/my.disk)

# DRIVERS / PLUGINS:

if ("$ENV{PLATFORM}" STREQUAL "x86_solo5")
Expand All @@ -47,10 +36,9 @@ else()
endif()

set(PLUGINS
# syslogd # Syslog over UDP
autoconf # configuration from config.json
# ...others
)


# include service build script
include($ENV{INCLUDEOS_PREFIX}/includeos/post.service.cmake)
9 changes: 4 additions & 5 deletions examples/demo_service/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
### IncludeOS Demo Service

To start, using boot:
```
mkdir build
cd build
cmake ..
make
../run.sh IncludeOS_example
boot .
```

This demo-service should start an instance of IncludeOS that brings up a minimal web service on port 80 with static content.

The default static IP is 10.0.0.42, unless running on a network with DHCP.
11 changes: 11 additions & 0 deletions examples/demo_service/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"net" : [
{
"iface": 0,
"config": "dhcp-with-fallback",
"address": "10.0.0.42",
"netmask": "255.255.255.0",
"gateway": "10.0.0.1"
}
]
}
19 changes: 5 additions & 14 deletions examples/demo_service/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,12 @@ http::Response handle_request(const http::Request& req)
return res;
}

void Service::start(const std::string&)
void Service::start()
{
// DHCP on interface 0
printf("*** Waiting up to 10 sec. for DHCP... ***\n");
auto& inet = net::Inet4::ifconfig(5.0, [](bool timeout) {
if (timeout) {
printf("*** Falling back to static network config ***\n");
// static IP in case DHCP fails
net::Inet4::stack().network_config(
{ 10,0,0,42 }, // IP
{ 255,255,255,0 }, // Netmask
{ 10,0,0,1 }, // Gateway
{ 10,0,0,1 }); // DNS
}
});
// Get the first IP stack
// It should have configuration from config.json
auto& inet = net::Super_stack::get<net::IP4>(0);

// Print some useful netstats every 30 secs
Timers::periodic(5s, 30s,
[&inet] (uint32_t) {
Expand Down
7 changes: 0 additions & 7 deletions examples/tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ set(SOURCES
service.cpp # ...add more here
)

#
# Service CMake options
# (uncomment to enable)
#

# MISC:

# To add your own include paths:
# set(LOCAL_INCLUDES ".")

Expand Down
11 changes: 11 additions & 0 deletions examples/tcp/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"net" : [
{
"iface": 0,
"config": "dhcp-with-fallback",
"address": "10.0.0.42",
"netmask": "255.255.255.0",
"gateway": "10.0.0.1"
}
]
}
9 changes: 2 additions & 7 deletions examples/tcp/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,9 @@ void handle_python_on_read(Connection_ptr client, const std::string& response) {
client->write(response);
}

void Service::start(const std::string&)
void Service::start()
{
// Static IP configuration will get overwritten by DHCP, if found
auto& inet = net::Inet4::ifconfig<0>(10);
inet.network_config({ 10,0,0,42 }, // IP
{ 255,255,255,0 }, // Netmask
{ 10,0,0,1 }, // Gateway
{ 8,8,8,8 }); // DNS
auto& inet = net::Super_stack::get<net::IP4>(0);

// Set up a TCP server on port 80
auto& server = inet.tcp().listen(80);
Expand Down
10 changes: 9 additions & 1 deletion examples/websocket/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"net": [
["10.0.0.42", "255.255.255.0", "10.0.0.1"]
{
"iface": 0,
"config": "static",
"address": "10.0.0.42",
"netmask": "255.255.255.0",
"gateway": "10.0.0.1"
}
]
}


Loading