GithubHelp home page GithubHelp logo

isabella232 / rebar_riak_core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from basho/rebar_riak_core

0.0 0.0 0.0 329 KB

rebar create template=riak_core appid=myapp

Shell 49.36% Erlang 50.27% Makefile 0.38%

rebar_riak_core's Introduction

Rebar Template for Generating Riak Core Applications

Usage

Install these templates into ~/.rebar/templates/:

make install

Verify Erlang installation (>= R15B01):

erl -version

Start with your first app:

mkdir firstapp
cd firstapp
wget http://cloud.github.com/downloads/basho/rebar/rebar && chmod u+x rebar
./rebar create template=riak_core appid=firstapp

Here is an excerpt of what the output should look like:

==> firstapp (create)
Writing .gitignore
Writing Makefile
Writing README.md
Writing rebar.config
...

Congratulations, you have the start of a Riak Core application that can be deployed to multiple nodes and joined together to form a multinode cluster. Lets compile and run it in console mode:

make rel
./rel/firstapp/bin/firstapp console

At this point you have a single node of firstapp running. Lets test it via the erlang console:

1> firstapp:ping().
{pong,753586781748746817198774991869333432010090217472}

Now shut it down:

2> q().

.. and lets test it using the cmdline, and test it via http request:

./rel/firstapp/bin/firstapp start

./rel/firstapp/bin/firstapp ping
curl http://localhost:8098/firstapp/ping

./rel/firstapp/bin/firstapp stop

devrel

Above we showed how to start a single node, but this isn't typically how other Riak Core based applications like Riak are tested. Instead, there is something called a devrel that allows one to easily set up a local N-node cluster. By defauly N is 4. You can change this by either editing the Makefile and changing DEVNODES to your prefered N, or by setting the variable DEVNODES before running the commands below.

Build the dev-nodes:

make devrel

This did create 4 separate instances under the dev/ dir; check it out:

ls dev

Now, lets start all the nodes:

for d in dev/dev*; do $d/bin/firstapp start; done

Verify that the nodes are up and running:

for d in dev/dev*; do $d/bin/firstapp ping; done

You should see four pong replies. At this point it is worth saying that you have four INDIVIDUAL firstapp nodes running. They are NOT aware of each other yet. In order to form a cluster you have to join the nodes. That has to be done only once. If a node, or the entire cluster, goes down it will remember the nodes it was connected to.

for d in dev/dev{2,3,4}; do $d/bin/firstapp-admin join [email protected]; done

Finally, to make sure they really all agree on the shape of the cluster you can ask if the ring is "ready."

./dev/dev1/bin/firstapp-admin ringready

Which returns something like:

TRUE All nodes agree on the ring ['[email protected]','[email protected]','[email protected]'],'[email protected]']

To verify you have a 4 node cluster and to see the distribution of the ring, run the member_status command:

./dev/dev1/bin/firstapp-admin member_status

Which returns:

================================= Membership ==================================
Status     Ring    Pending    Node
-------------------------------------------------------------------------------
valid      25.0%      --      '[email protected]'
valid      25.0%      --      '[email protected]'
valid      25.0%      --      '[email protected]'
valid      25.0%      --      '[email protected]'
-------------------------------------------------------------------------------
Valid:4 / Leaving:0 / Exiting:0 / Joining:0 / Down:0

Pretty cool!! Your riak-core cluster is up and running.

And in case you want to stop all the nodes:

for d in dev/dev*; do $d/bin/firstapp stop; done

stage and stagedevrel

For rapid, iterative development both make rel and make devrel have a stage counterpart. Running either:

make stage

or

make stagedevrel

will cause the deps and apps directories to be symlinked into the release(s) lib directory. This means you can edit your apps source code, recompile it, and load it on to the running node(s). You can either start mochiweb reloader

reloader:start().

when attached to the node(s), which will cause any changes to be automatically reloaded. Or attach to a running node and run

`l(mod_name)`.

to reload a specific module.

rebar_riak_core's People

Contributors

russelldb avatar rzezeski avatar neuhausler avatar jnewland avatar argv0 avatar licenser avatar bkerley avatar jadeallenx avatar aschepis avatar vinoski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.