From 655afb4a68a485c0145dac3abbdfc9ccb76c7c11 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Thu, 5 May 2011 17:35:05 -0700 Subject: [PATCH 01/14] fix repos needed for plugins --- lib/template/project/plugins/Plugins.scala.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/template/project/plugins/Plugins.scala.erb b/lib/template/project/plugins/Plugins.scala.erb index 36e58ed..e51ac82 100644 --- a/lib/template/project/plugins/Plugins.scala.erb +++ b/lib/template/project/plugins/Plugins.scala.erb @@ -13,8 +13,10 @@ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { } else { super.repositories ++ Seq("twitter.com" at "http://maven.twttr.com/") } - override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++ repositories + override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++ repositories ++ + Set("scala-tools" at "http://scala-tools.org/repo-releases/", + "freemarker" at "http://freemarker.sourceforge.net/maven2/") - val standardProject = "com.twitter" % "standard-project" % "0.11.16" + val standardProject = "com.twitter" % "standard-project" % "0.12.3" val sbtThrift = "com.twitter" % "sbt-thrift" % "1.3.11" } From f2c4bacf181703fe27995f64dee3a7eb14f80dd5 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Thu, 5 May 2011 18:50:56 -0700 Subject: [PATCH 02/14] update sbt-thrift --- lib/template/project/plugins/Plugins.scala.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template/project/plugins/Plugins.scala.erb b/lib/template/project/plugins/Plugins.scala.erb index e51ac82..73d616e 100644 --- a/lib/template/project/plugins/Plugins.scala.erb +++ b/lib/template/project/plugins/Plugins.scala.erb @@ -18,5 +18,5 @@ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { "freemarker" at "http://freemarker.sourceforge.net/maven2/") val standardProject = "com.twitter" % "standard-project" % "0.12.3" - val sbtThrift = "com.twitter" % "sbt-thrift" % "1.3.11" + val sbtThrift = "com.twitter" % "sbt-thrift" % "1.4.1" } From eb713ae3310d11cbfb5ca383463dd6618ea40e50 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Wed, 18 May 2011 14:41:59 -0700 Subject: [PATCH 03/14] sbt-thrift 1.4.4 --- lib/template/project/plugins/Plugins.scala.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template/project/plugins/Plugins.scala.erb b/lib/template/project/plugins/Plugins.scala.erb index 73d616e..2dff9d8 100644 --- a/lib/template/project/plugins/Plugins.scala.erb +++ b/lib/template/project/plugins/Plugins.scala.erb @@ -18,5 +18,5 @@ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { "freemarker" at "http://freemarker.sourceforge.net/maven2/") val standardProject = "com.twitter" % "standard-project" % "0.12.3" - val sbtThrift = "com.twitter" % "sbt-thrift" % "1.4.1" + val sbtThrift = "com.twitter" % "sbt-thrift" % "1.4.4" } From 265fb54e46cdb7f9845d8c53e6acd9cfd7e55e49 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Wed, 18 May 2011 17:54:27 -0700 Subject: [PATCH 04/14] update versions in gemfile and mention how to use it in a comment --- lib/template/Gemfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/template/Gemfile b/lib/template/Gemfile index 6bc316d..50269f5 100644 --- a/lib/template/Gemfile +++ b/lib/template/Gemfile @@ -1,7 +1,8 @@ +# use "bundle install" to update gems; "gem install bundler" to install bundler. source :rubygems source "http://gems.local.twitter.com" -gem "thrift_client", "0.6" -gem "thrift", "0.5" +gem "thrift_client", "0.6.2" +gem "thrift", "0.6" gem "railsless-deploy" gem "capistrano" gem "twitter-cap-utils", "~>0.8.0" From a100a7d0c5f210c30fe5fc585d5ec7beb6391a03 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 24 May 2011 19:59:01 -0700 Subject: [PATCH 05/14] fix plugins --- lib/template/project/plugins/Plugins.scala.erb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/template/project/plugins/Plugins.scala.erb b/lib/template/project/plugins/Plugins.scala.erb index 2dff9d8..db287e4 100644 --- a/lib/template/project/plugins/Plugins.scala.erb +++ b/lib/template/project/plugins/Plugins.scala.erb @@ -11,12 +11,13 @@ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { } else if (isSBTTwitter) { Set("twitter.artifactory" at "http://artifactory.local.twitter.com/repo/") } else { - super.repositories ++ Seq("twitter.com" at "http://maven.twttr.com/") + super.repositories ++ Set( + "twitter.com" at "http://maven.twttr.com/", + "scala-tools" at "http://scala-tools.org/repo-releases/", + "freemarker" at "http://freemarker.sourceforge.net/maven2/" + ) } - override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++ repositories ++ - Set("scala-tools" at "http://scala-tools.org/repo-releases/", - "freemarker" at "http://freemarker.sourceforge.net/maven2/") - + override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++ repositories val standardProject = "com.twitter" % "standard-project" % "0.12.3" val sbtThrift = "com.twitter" % "sbt-thrift" % "1.4.4" } From eff5af9f38f4b687350ff8f0969eec1d15ed5e81 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 24 May 2011 20:07:08 -0700 Subject: [PATCH 06/14] use newer standard-project, and make thirft target namespace an override --- lib/template/project/build/BirdNameProject.scala.erb | 2 +- lib/template/project/plugins/Plugins.scala.erb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/template/project/build/BirdNameProject.scala.erb b/lib/template/project/build/BirdNameProject.scala.erb index e2c5cbd..4751579 100644 --- a/lib/template/project/build/BirdNameProject.scala.erb +++ b/lib/template/project/build/BirdNameProject.scala.erb @@ -28,7 +28,7 @@ class BirdNameProject(info: ProjectInfo) extends StandardServiceProject(info) val util = "com.twitter" % "util" % "1.8.3" override def originalThriftNamespaces = Map("BirdName" -> "com.twitter.birdname.thrift") - val scalaThriftTargetNamespace = "com.twitter.birdname" + override val scalaThriftTargetNamespace = "com.twitter.birdname" val slf4jVersion = "1.5.11" val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion withSources() intransitive() diff --git a/lib/template/project/plugins/Plugins.scala.erb b/lib/template/project/plugins/Plugins.scala.erb index db287e4..6b33855 100644 --- a/lib/template/project/plugins/Plugins.scala.erb +++ b/lib/template/project/plugins/Plugins.scala.erb @@ -18,6 +18,7 @@ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { ) } override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++ repositories - val standardProject = "com.twitter" % "standard-project" % "0.12.3" + + val standardProject = "com.twitter" % "standard-project" % "0.12.7" val sbtThrift = "com.twitter" % "sbt-thrift" % "1.4.4" } From 6a2b3baabab1582f295473b2a07020a41579fde7 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 14 Jun 2011 23:16:22 -0700 Subject: [PATCH 07/14] add intellij info from the wiki. --- lib/template/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/template/README.md b/lib/template/README.md index 3ef1411..7b94740 100644 --- a/lib/template/README.md +++ b/lib/template/README.md @@ -8,6 +8,16 @@ properly, you may want to: There is a tutorial for what to do next, which you can find in the scala-bootstrapper README.rdoc file. +# Configuring Intellij + +If you want to setup Intellij, it has to happen off to the side: + + $ sbt + > *sbtIdeaRepo at http://mpeltonen.github.com/maven/ + > *idea is com.github.mpeltonen sbt-idea-processor 0.4.0 + > update + > idea + # Documenting your project Add documentation here! Eventually, you'll be able to publish this to From 636302635c78f6903834ed0641c365403d3c2fab Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 14 Jun 2011 23:16:43 -0700 Subject: [PATCH 08/14] fixes from NHO class. --- lib/template/TUTORIAL.md | 2 +- lib/template/src/scripts/console.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/template/TUTORIAL.md b/lib/template/TUTORIAL.md index f5d71bd..12107ae 100644 --- a/lib/template/TUTORIAL.md +++ b/lib/template/TUTORIAL.md @@ -34,8 +34,8 @@ for your service can be found [here](http://wiki.apache.org/thrift/Tutorial) Your service implements simple get() and put() methods. Once you have your server running, as above, bring up a different shell and: - $ bundle install $ cd birdname + $ bundle install $ ./src/scripts/console $ $client $ $client.put("key1", "valueForKey") diff --git a/lib/template/src/scripts/console.erb b/lib/template/src/scripts/console.erb index f9467fd..725b944 100644 --- a/lib/template/src/scripts/console.erb +++ b/lib/template/src/scripts/console.erb @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -$: << File.dirname(__FILE__) + "/../../../target/gen-rb" +$: << File.dirname(__FILE__) + "/../../target/gen-rb" require "rubygems" require "bundler/setup" From 457be3d491a034b109c6796ba32c76755bf0f031 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 14 Jun 2011 23:24:41 -0700 Subject: [PATCH 09/14] oh wait, what's wrong is that the instructions were incorrect --- lib/template/TUTORIAL.md | 2 +- lib/template/src/scripts/console.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/template/TUTORIAL.md b/lib/template/TUTORIAL.md index 12107ae..276eca9 100644 --- a/lib/template/TUTORIAL.md +++ b/lib/template/TUTORIAL.md @@ -36,7 +36,7 @@ your server running, as above, bring up a different shell and: $ cd birdname $ bundle install - $ ./src/scripts/console + $ ./dist/birdname/scripts/console $ $client $ $client.put("key1", "valueForKey") $ $client.get("key1") diff --git a/lib/template/src/scripts/console.erb b/lib/template/src/scripts/console.erb index 725b944..f9467fd 100644 --- a/lib/template/src/scripts/console.erb +++ b/lib/template/src/scripts/console.erb @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -$: << File.dirname(__FILE__) + "/../../target/gen-rb" +$: << File.dirname(__FILE__) + "/../../../target/gen-rb" require "rubygems" require "bundler/setup" From f65f6b6a05f7487937c636c7b096f8c1c752c934 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Fri, 17 Jun 2011 13:27:45 -0700 Subject: [PATCH 10/14] verify that your service is running, stop the service, and mention finagle and its documentation --- lib/template/TUTORIAL.md | 43 +++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/lib/template/TUTORIAL.md b/lib/template/TUTORIAL.md index 276eca9..2d11dc2 100644 --- a/lib/template/TUTORIAL.md +++ b/lib/template/TUTORIAL.md @@ -21,13 +21,26 @@ or you can ask sbt to run your service: $ sbt 'run -f config/development.scala' +### Verify that the service is running + +The java/sbt command-lines will "hang" because the server is running in the +foreground. (In production, we use libslack-daemon to wrap java processes into +unix daemons.) Go to another terminal and check for a logfile. If your server +is named "memcache", there should be a `memcache.log` with contents like this: + + INF [20110615-14:05:41.656] stats: Starting JsonStatsLogger + INF [20110615-14:05:41.674] admin: Starting TimeSeriesCollector + DEB [20110615-14:05:41.792] nio: Using the autodetected NIO constraint level: 0 + +That's your indication that the server is running. :) + ### View the Thrift IDL for your service -The IDL for your service is in src/main/thrift/birdname.thrift. The +The IDL for your service is in `src/main/thrift/birdname.thrift`. The Thrift compiler uses the IDL to generate bindings for various languages, making it easy for scripts in those languages to talk to your service. More information about Thrift and how to write an IDL -for your service can be found [here](http://wiki.apache.org/thrift/Tutorial) +for your service can be found [here](http://wiki.apache.org/thrift/Tutorial). ### Call your service from ruby @@ -37,17 +50,17 @@ your server running, as above, bring up a different shell and: $ cd birdname $ bundle install $ ./dist/birdname/scripts/console - $ $client - $ $client.put("key1", "valueForKey") - $ $client.get("key1") + >> $client + >> $client.put("key1", "valueForKey") + >> $client.get("key1") ### Look at the stats for your service By default, your project is configured to use [Ostrich](https://github.com/twitter/ostrich), a library for service -configuration, administration, and stats reporting. Your config file -in config/development.scala defines which port ostrich uses for admin -requests. You can view the stats via that port: +configuration, administration, and stats reporting. Your config file +in `config/development.scala` defines which port ostrich uses for admin +requests. You can view the stats via that port: $ curl localhost:9900/stats.txt counters: @@ -59,9 +72,21 @@ requests. You can view the stats via that port: Ostrich also stores historial stats data and can build [graphs](http://localhost:9900/graph/) for you. +### Stop the service + +You can ask the server to shutdown over the admin port also: + + $ curl localhost:9990/shutdown.txt + ok + ### View the implementation of get() and put() -Take a look at src/main/scala/com/twitter/birdname/BirdNameServiceImpl.scala. +In `src/main/scala`, take a look at `BirdNameServiceImpl.scala`. This will +probably have a different name, based on what you called your server. + +The base interface is specified by thrift. Additionally, we're using Twitter's +async I/O framework: finagle. Finagle (and a lot of great documentation about +it) is hosted here: https://github.com/twitter/finagle ### Try adding some timers and counters From 60e584bda5b9c8ab80b1306196561055eab2a343 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Fri, 17 Jun 2011 15:15:20 -0700 Subject: [PATCH 11/14] birdname --- lib/template/TUTORIAL.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/template/TUTORIAL.md b/lib/template/TUTORIAL.md index 2d11dc2..4b3e2c3 100644 --- a/lib/template/TUTORIAL.md +++ b/lib/template/TUTORIAL.md @@ -26,7 +26,7 @@ or you can ask sbt to run your service: The java/sbt command-lines will "hang" because the server is running in the foreground. (In production, we use libslack-daemon to wrap java processes into unix daemons.) Go to another terminal and check for a logfile. If your server -is named "memcache", there should be a `memcache.log` with contents like this: +is named "birdname", there should be a `birdname.log` with contents like this: INF [20110615-14:05:41.656] stats: Starting JsonStatsLogger INF [20110615-14:05:41.674] admin: Starting TimeSeriesCollector @@ -64,9 +64,9 @@ requests. You can view the stats via that port: $ curl localhost:9900/stats.txt counters: - Nho2/connects: 1 - Nho2/requests: 2 - Nho2/success: 2 + BirdName/connects: 1 + BirdName/requests: 2 + BirdName/success: 2 ... Ostrich also stores historial stats data and can build @@ -81,8 +81,8 @@ You can ask the server to shutdown over the admin port also: ### View the implementation of get() and put() -In `src/main/scala`, take a look at `BirdNameServiceImpl.scala`. This will -probably have a different name, based on what you called your server. +In `src/main/scala`, take a look at `BirdNameServiceImpl.scala`. (This may +have a different name, based on what you called your server.) The base interface is specified by thrift. Additionally, we're using Twitter's async I/O framework: finagle. Finagle (and a lot of great documentation about From cf4ad55ef0303f967db3858faf5557f971eefd25 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Fri, 17 Jun 2011 21:28:39 -0700 Subject: [PATCH 12/14] apparently -verbosegc is redundant with +PrintGCDetails --- lib/template/src/scripts/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template/src/scripts/startup.sh b/lib/template/src/scripts/startup.sh index 18134ac..4aa06ba 100644 --- a/lib/template/src/scripts/startup.sh +++ b/lib/template/src/scripts/startup.sh @@ -18,7 +18,7 @@ STAGE="production" HEAP_OPTS="-Xmx4096m -Xms4096m -XX:NewSize=768m" GC_OPTS="-XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=1000 -XX:GCTimeRatio=99" -GC_LOG_OPTS="-verbosegc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC" +GC_LOG_OPTS="-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC" GC_LOG="-Xloggc:/var/log/$APP_NAME/gc.log" DEBUG_OPTS="-XX:ErrorFile=/var/log/$APP_NAME/java_error%p.log" JAVA_OPTS="-server -Dstage=$STAGE $GC_OPTS $GC_LOG_OPTS $GC_LOG $HEAP_OPTS $DEBUG_OPTS" From 5f879e9bcf2e83b64560eac1a4bb321016be2da3 Mon Sep 17 00:00:00 2001 From: Evan Meagher Date: Wed, 13 Jul 2011 11:04:27 -0700 Subject: [PATCH 13/14] Fix admin port in shutdown example. The code example in the "Stop the service" section currently lists port 9990 instead of the default admin port 9900. Changed the code example so it's more straightforward for newcomers. --- lib/template/TUTORIAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template/TUTORIAL.md b/lib/template/TUTORIAL.md index 4b3e2c3..8fffb13 100644 --- a/lib/template/TUTORIAL.md +++ b/lib/template/TUTORIAL.md @@ -76,7 +76,7 @@ Ostrich also stores historial stats data and can build You can ask the server to shutdown over the admin port also: - $ curl localhost:9990/shutdown.txt + $ curl localhost:9900/shutdown.txt ok ### View the implementation of get() and put() From 5d31b2f41f0968bfaece0694424748a46a7b0e2d Mon Sep 17 00:00:00 2001 From: Evan Meagher Date: Wed, 13 Jul 2011 15:27:21 -0700 Subject: [PATCH 14/14] Fix Specs filename in tutorial code example. The tutorial currently states that specs are in file BirdNameServiceImpl.scala. Changed this to BirdNameServiceSpec.scala. --- lib/template/TUTORIAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template/TUTORIAL.md b/lib/template/TUTORIAL.md index 8fffb13..ffb5313 100644 --- a/lib/template/TUTORIAL.md +++ b/lib/template/TUTORIAL.md @@ -127,7 +127,7 @@ example: framework that allows you to write semi-human-readable descriptions of how your service should behave and test that those descriptions are valid. You already have some Specs code for your project in -src/test/scala/com/twitter/birdname/BirdNameServiceImpl.scala. Check +src/test/scala/com/twitter/birdname/BirdNameServiceSpec.scala. Check out the existing test and add a new one for the counter functionality we just added.