-
Notifications
You must be signed in to change notification settings - Fork 323
Vagrant Example
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
- This can be found at: http://www.virtualbox.org
- This can be found at: http://vagrantup.com
vagrant box add lucid64 http://files.vagrantup.com/lucid64.box
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.
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
You can restart an instance by using the reload command and passing it optional instances
vagrant reload vagrant reload skynet1 skynet2
You can stop an instance by using the halt command and passing it optional instances
vagrant halt vagrant halt skynet1 skynet2
You can log on to each of these boxes to inspect their logs or debug by using vagrant's ssh command
vagrant ssh skynet1
If you ever feel like you have completely hosed up one of your nodes/hosts you can do a clean setup by issuing the following commands
vagrant destroy skynet1 vagrant up skynet1
As before the initial up will take a while, everything needs to download and rebuild (not the virtualbox though). If you don't supply a node name than it will destroy all of them which is probably not what you want.
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)
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.101 in your browser to watch it live update as all this is taking place