Home

caf 0.2.3

CAF.js (Cloud Assistant Framework)

Co-design permanent, active, stateful, reliable cloud proxies with your web app and IoT devices.

See http://www.cafjs.com

CAF

Build Status

This repository provides a consistent snapshot of all the other CAF sub-projects. They are tested together to create a CAF release. CAF tools help apps to stick to modules of a particular release by using npm link and npm shrinkwrap under the hood.

Getting Started

Note that the tools only support npm v2. Use node.js v4.X.X or, in more recent versions of node.js, downgrade npm. Also, all our development is done with Linux.

Clone this repository (git clone https://github.com/cafjs/caf.git) within your $HOME directory, and update submodules:

  cd caf; git submodule update --init

Satisfy node dependencies and create symbolic links to CAF libs with:

./tools/setupLinks.sh

The assumption is that these links are created within your $HOME directory. If you use nvm (https://github.com/creationix/nvm) to manage node.js (highly recommended!), they will be under $HOME/.nvm.

If that is not the case, you need to override the default options in cafjs run, see external:caf_dcinabox (https://cafjs.github.io/api/caf_dcinabox).

Install the tools:

cd tools/caf_dcinabox; npm install -g .

and now let's build and run locally a simple app:

cd apps/caf_helloworld; cafjs build; cafjs run helloworld

The first time we call cafjs run it takes a few minutes, because it downloads the core Docker images. Ignore timeout exceptions during that time, it retries.

The app server URL is http://root-launcher.vcap.me (DNS always resolves *.vcap.me to 127.0.0.1, i.e., the local loop). With your browser, login with user foo and password pleasechange, and then click the + icon to add a helloworld CA. Fill the form as follows:

  • Application publisher: root
  • Application name: helloworld
  • CA name: anything containing ASCII characters and numbers.

and a counter example should appear. Use the + again to create other CAs, and then select the menu on the top right to switch between them.

To stop it, a single Control-C will initiate a gentle container shutdown but, for the impatient, a second Control-C will brute force a clean-up.

In both cases we should be able to restart without losing the CA's state. This state is checkpointed in a Redis container that mounts a host volume (log file in /tmp/redis/appendonly.aof, host port 6380). To start from scratch, delete the log file in the host.

Using the cafjs command we can also simulate devices, build container images to publish in our cloud service, i.e., https://root-launcher.cafjs.com, or reset after a hang. See external:caf_dcinabox (https://cafjs.github.io/api/caf_dcinabox) for details.