Skip to content
Kristian Ionescu edited this page Nov 12, 2013 · 57 revisions

NOTE: these instructions might only work with the Ubuntu 12.04 LTS 64bit release!

To run the project, you first need to make sure that you have Erlang and R installed, and for some functionality in R to work you need to manually install a package for it..

Install Erlang

Download erlang: http://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_16.b.1~ubuntu~precise_amd64.deb

Install it:

sudo dpkg -i <deb file>

Install R (and friends)

The backend system uses R for statistical computations, such as time series forecasting (a.k.a predictions). It can be used through calls to the API, and uses an internal interface to feed commands from Erlang to R and get back results. In order to compile the project, two of three parts are necessary, and in order to run time series forecasting, an extra step is required.

###R Installing just R requires only a few simple commands, but after the installation has finished you are required to manually set an environment variable. This will probably be fixed in the future, but doing it manually can't do any harm.

installing R

Using a terminal, you enter the following commands:

    sudo add-apt-repository "deb http://ftp.sunet.se/pub/lang/CRAN/bin/linux/ubuntu precise/"
    sudo apt-get update
    sudo apt-get install r-base

If you don't have add-apt-repository you can get it via:

    sudo apt-get install software-properties-common

Now you should be ready to run R. If you run

make install

it should now be able to download and compile rErlang, and the rest of the project.

Setting R_HOME (important!)

Unfortunately, R does not set the variable R_HOME to what we need to use it from within our engine. There are two ways to set this variable:

  • For each session, before you start the engine, run
export R_HOME=/usr/lib/R

in the terminal. NO BLANKSPACES AROUND THE = SIGN!

  • In $HOME/.profile, insert the line
export R_HOME="/usr/lib/R"

This will set the variable when you log in to the system (will not take effect until you relog/restart ubuntu). This way you don't have to worry about remembering to set it every time you start a new terminal.

We hope this step will become redundant in the future, but doing it is not going to break anything.

Forecast package in R

This one needs to be done manually, but is only required for actually running predictions. Start R in a terminal with the command

R

Inside R, enter the following:

install.packages("forecast")

choose y twice, then select the mirror you want to use (preferably one close to you). Once the installation is done, you can quit R with

q()

You do not have to save the workspace, so just press n.

You should now be ready to go.

rErlang

rErlang is our internal api for connecting Erlang and R. It is included as a dependency in our project and is automatically downloaded and compile when you run

make install

It does require R to compile, so make sure you have done that first.

Downloading the project

All you need to do is check out our project. We recommend using the develop branch, as it is the latest (most) stable. The demo branch periodically has some newer functionality, but stability is not guaranteed.

Downloading dependencies

The following commands will install the needed dependencies:

sudo apt-get install -qq xsltproc
make install

The elasticsearch server

Configuring ES

NOTE: Since you change your config file in the lib folder, it will not be saved. If you do a new make install or a make clean_libs then your changes will be removed!

The configuration of ES can be found in the lib/elasticsearch/config folder. The file of interest is elasticsearch.yml

Most of the fields are commented out and this means that they will use the defaults. Some options that are good to know:

cluster.name: my_cluster_name        # Defines the name of the cluster
node.name: "My Unique Node Name"     # Defines the unique node name
path.data: /my_path/data             #Define where you want the data to be
path.work: /my_path/work             #Define where you want the temporary files
path.logs: /my_path/logs             #Define where you want the logs

If you want the data to be persistant, you need to specify the data path. This might also cause you to have to run es with sudo sudo make run_es More info about the options can be found in the file.

Running ES

This will run the elasticsearch server on your computer.

make run_es

Our back-end can be started without it, but the API can not be used unless it is started.

Run the application

This command starts the back-end service, enabling the API.

make run

You can also use the sensec.sh script to start RabbitMQ, ElasticSearch and Sensor-Cloud by using the following command:

sudo ./sensec.sh start

This will call the service wrappers for RabbitMQ, ElasticSearch and running Sensor-Cloud in erlang, the tasks are running in the background , Sensor-Cloud is running with the -noshell command so that erlang is not terminated if the task is running in the background. To close the services you can use:

sudo ./sensec.sh stop

Running tests

To run the test, you should make sure that the service is not already running. If you did a make run before, make sure to quit it, using q().. Now you can do a make test, make test will start the service, run the tests and then shut the service down.

make test
Clone this wiki locally