Skip to content
This repository was archived by the owner on Dec 5, 2017. It is now read-only.

Vagrant Example

erikstmartin edited this page Sep 12, 2012 · 8 revisions

In order to help simulate a real world environment, we've setup Vagrant and chef recipes to allow you to deploy a mock setup.

Vagrant is a way of scripting the creation and provisioning of multiple headless VirtualBoxes

VirtualBox

Install Virtualbox

Vagrant

Install Vagrant
Setup Vagrant Box
vagrant box add base http://files.vagrantup.com/lucid64.box
vagrant init

Skynet

In the examples directory there is a Vagrantfile configured to emulate 5 hosts/nodes. You can adjust this number with the variable at the top of Vagrantfile.

Deploy

You can run the following command from within the examples directory to deploy all 5 nodes.

Keep in mind the first time running this will take quite a bit of time because it will download git, mercurial, go, doozer, mongodb, skynet and all their dependencies, but will run much faster on subsequent starts.

vagrant up

If you'd prefer to start instances individually (which is prefered, especially the first time. That's a long wait for 5 instances to install the first time). You can supply just the names of the instances you want to start (skynet1-skynet5)

vagrant up skynet1
vagrant up skynet1 skynet2
Restart

You can restart an instance by using the reload command and passing it optional instances

vagrant reload
vagrant reload skynet1 skynet2
Shutdown

You can stop an instance by using the halt command and passing it optional instances

vagrant halt
vagrant halt skynet1 skynet2
Gaining access

You can log on to each of these boxes to inspect their logs or debug by using vagrant's ssh command

vagrant ssh skynet1
Developing

Inside the top of examples/Vagrantfile you can set the branch you wish to be deployed and a boolean flag for whether to force vagrant to update your skynet repo and rebuild the services in case you want to deploy your current branch

You can also set your Environment Variables so that locally started services/daemons/dashboards/clients connect to your vagrant setup, so that you can utilize the doozer and mongo installs on your vagrant host. The ip addresses are 192.168.126.10<instance> (example: 192.168.126.101 is skynet1 the master node with mongodb and doozer installed on it)

Playing around with examples

In the examples directory you can find examples/service an example service which just upcases the string it's sent, and examples/testing/fibonacci/fibservice an example service that calls other instances of itself to return the number at the specified index in the fibonacci series.

Both of these are deployed as part of the vagrant example.

If you check out the examples/testing/vagranttests directory there is a script that on loop requests random data from these 2 services and validates their responses, when killed with Ctrl-C it will spit out the number of requests sent, time run, average requests per second, and the number of successful vs failed requests.

It takes a --doozer flag of the doozer instance to connect to. As well as an optional number of concurrent requests to make

go build
./vagranttests --doozer=192.168.126.101:8046 --requests=10

============================================================================
Completed in 2144 Milliseconds, 1907.182836 Requests/s

Total Requests: 4089, Successful: 4089 (100%), Failed: 0 (0%)

From here it's up to you, ssh in kill some services or kill -9 some services and watch them restart and continue on as if nothing happened. Use the Sky command to deploy new instances and watch them start taking requests, unreqister/register services, stop them etc.

Checkout the Dashboard at http://192.168.126.1010 in your browser to watch it live update as all this is taking place

Clone this wiki locally