Skip to content

Example Application

brharrington edited this page Mar 9, 2013 · 4 revisions

The easiest way to get started is to run the example application. The commands to get the demo app running are:

$ git clone https://github.com/Netflix/servo.git
$ cd servo
$ ./gradlew servo-example:run

This will kick off a simple web server that by default listens on port 12345 and logs metrics to the /tmp directory every 5 seconds. The main endpoint just echoes back whatever data is received in the request. To see it actually do something in another terminal run a command to send some data to the server, for example:

$ seq 1 100 | xargs -n1 curl -s http://localhost:12345/echo -d | wc
       0       1     192

You can then grep the output files and see that the bytesReceived counter shows we received data:

$ grep -P '^bytesReceived\s+.*class=EchoHandler.*' /tmp/servo-example_* | tail -n5
/tmp/servo-example_2013_09_03_04_02_41_773.log:bytesReceived	class=EchoHandler,type=COUNTER	2013-09-03T04:02:41.773	0.0
/tmp/servo-example_2013_09_03_04_02_46_779.log:bytesReceived	class=EchoHandler,type=COUNTER	2013-09-03T04:02:46.778	38.36163836163836
/tmp/servo-example_2013_09_03_04_02_51_785.log:bytesReceived	class=EchoHandler,type=COUNTER	2013-09-03T04:02:51.784	0.0
/tmp/servo-example_2013_09_03_04_02_56_790.log:bytesReceived	class=EchoHandler,type=COUNTER	2013-09-03T04:02:56.789	0.0
/tmp/servo-example_2013_09_03_04_03_01_796.log:bytesReceived	class=EchoHandler,type=COUNTER	2013-09-03T04:03:01.795	0.0

You can shutdown the example app by sending a request to the exit endpoint:

$ curl -s http://localhost:12345/exit

For more details have a look at the source code.

Clone this wiki locally