Permalink
Browse files

Adding request logging and GET POST param overrides

  • Loading branch information...
1 parent 6f8afb4 commit c2b6cdd952e4e45fcede39763e07188f5df8f012 @kelvl kelvl committed Jun 17, 2013
View
@@ -0,0 +1,60 @@
+.PHONY: test prep upload ci clean build
+
+SBT_URL = "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch//0.12.3/sbt-launch.jar"
+SBT_LAUNCH = "sbt-launch.jar"
+
+CI = noop
+
+ifeq ($(REALM),dev)
+ CI = test
+endif
+
+ARTIFACT = $(PACKAGE_NAME)-$(shell echo $$PACKAGE_VERSION | sed -e "s/-SNAPSHOT/_SNAPSHOT/")-$(BUILD_NUMBER)
+
+blar:
+ echo $(ARTIFACT)
+
+prep:
+ wget $(SBT_URL) -O $(SBT_LAUNCH)
+
+clean:
+ rm -rf ./bin
+ find $(HOME)/.ivy2/ -name "*-SNAPSHOT.jar" -exec rm {} \; || true
+ rm -f $(SBT_LAUNCH)
+
+test: clean prep
+ java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss16M -Dsbt.log.noformat=true -jar $(SBT_LAUNCH) clean compile jacoco:cover
+
+build: clean prep
+ java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss16M -Dsbt.log.noformat=true -jar $(SBT_LAUNCH) clean compile test assembly
+ mkdir -p ./bin/
+ mv target/*-assembly-*.jar ./bin/$(ARTIFACT).jar
+
+
+# As soon as builds stop happening on stage, remove this
+define COVERAGE_XML
+<?xml version="1.0" ?>
+<!DOCTYPE coverage
+SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
+<coverage branch-rate="0" line-rate="0.4933" timestamp="$(date +%s)000" version="3.5.1">
+<!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage -->
+<packages>
+</packages>
+</coverage>
+endef
+
+define JUNIT_XML
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuite name="nosetests" tests="1" errors="0" failures="0" skip="0">
+<testcase classname="FAKE_STAGE_OUTPUT" name="FAKE_STAGE_OUTPUT" time="0.001"/>
+</testsuite>
+endef
+
+export JUNIT_XML
+export COVERAGE_XML
+
+noop:
+ echo "$$JUNIT_XML" > testlog.xml
+ echo "$$COVERAGE_XML" > coverage.xml
+
+ci: $(CI)
View
103 README.md
@@ -24,6 +24,7 @@ This generates an assembled Jar with all dependencies in `/target/shadow-assembl
## Installing
+<<<<<<< HEAD
No escalated privledges needed unless you are using privileged ports. Just copy the Jar built in the previous step on to your existing server.
## Configuring
@@ -101,4 +102,106 @@ To run them, use: `sbt test`
* [Scala](http://www.scala.org)
* [Spray](http://www.spray.io)
* [Akka](http://www.akka.io)
+=======
+No escalated privledges needed unless you are using privileged ports.
+### From Source
+
+Just copy the Jar built in the build step on to your existing server.
+
+Run `java -jar -Dconfig.file=application.conf shadow-assembly-<VERSION>.jar`
+
+## From RPM
+
+Running `yum install kelvin.shadow.scala` should install the latest version of shadow in `/mnt/services/shadow`
+
+`cd /mnt/services/shadow`
+
+Run `java -jar -Dconfig.file=application.conf bin/shadow-<version>.jar`
+
+>>>>>>> ea987f2... Adding readme and example configuration
+
+## Configuring
+
+Make a copy of the example configuration `application.conf.example` and change the settings to fit your environment.
+
+
+## Shadow specific configuration
+
+
+```
+akka {
+ loglevel = INFO
+}
+
+shadow {
+ version = "0.1-SNAPSHOT"
+
+ proxy-host = localhost
+ proxy-port = 8000
+
+ ui-host = localhost
+ ui-port = 8081
+
+ results-log = "logs/results.log"
+
+ trueServer {
+
+ host = "httpbin.org"
+ port = 80
+
+ query-param-overrides {
+ }
+
+ form-param-overrides {
+ }
+
+ }
+
+ shadowServer {
+
+ host = "httpbin.org"
+ port = 80
+
+ query-param-overrides {
+ test = ["hello"]
+ }
+
+ form-param-overrides {
+ test2 = ["world"]
+ }
+
+ }
+}
+
+spray.can.server {
+ server-header = shadow-server/${shadow.version}
+ request-timeout = 15s
+ stats-support = true
+}
+
+spray.can.client {
+ user-agent-header = shadow/${shadow.version}
+}```
+
+## Running
+
+Running `java -jar -Dconfig.file=application.conf shadow-assembly-<VERSION>.jar` will start the server in the foreground.
+
+We recommend using a supervisor such as `jsvc` or `runit` to manage running shadow
+
+Be default, the UI can be accessed at [http://localhost:8081](http://localhost:8081)
+
+## Testing
+
+Tests are found under `src/main/test/scala/`
+
+To run them, use: `sbt test`
+
+## Based upon
+
+* [AngularJS](http://angularjs.org/)
+* [jsdiff](https://github.com/kpdecker/jsdiff)
+* [Scala](http://www.scala.org)
+* [Spray](http://www.spray.io)
+* [Akka](http://www.akka.io)
View
@@ -3,38 +3,51 @@ akka {
}
shadow {
- version = "0.1-SNAPSHOT"
-
- # host and port to listen to incoming requests
- proxy-host = localhost
- proxy-port = 8000
-
- # host and port for the ui
- ui-host = localhost
- ui-port = 8081
-
- # host and port of the service we are transitioning from
- # shadow returns responses from this host
- trueServer {
- host = "httpbin.org"
- port = 80
- }
-
- # host and port of the service we are transitioning to
- shadowServer {
- host = "httpbin.org"
- port = 80
- }
+ version = "0.1-SNAPSHOT"
+
+ proxy-host = localhost
+ proxy-port = 8000
+
+ ui-host = localhost
+ ui-port = 8081
+
+ results-log = "logs/results.log"
+
+ trueServer {
+
+ host = "httpbin.org"
+ port = 80
+
+ query-param-overrides {
+ }
+
+ form-param-overrides {
+ }
+
+ }
+
+ shadowServer {
+
+ host = "httpbin.org"
+ port = 80
+
+ query-param-overrides {
+ test = ["hello"]
+ }
+
+ form-param-overrides {
+ test2 = ["world"]
+ }
+
+ }
}
spray.can.server {
server-header = shadow-server/${shadow.version}
-
- # max request timeout
request-timeout = 15s
stats-support = true
}
spray.can.client {
user-agent-header = shadow/${shadow.version}
-}
+}
View
@@ -0,0 +1,53 @@
+akka {
+ loglevel = INFO
+}
+
+shadow {
+ version = "0.1-SNAPSHOT"
+
+ proxy-host = localhost
+ proxy-port = 8000
+
+ ui-host = localhost
+ ui-port = 8081
+
+ results-log = "logs/results.log"
+
+ trueServer {
+
+ host = "httpbin.org"
+ port = 80
+
+ query-param-overrides {
+ }
+
+ form-param-overrides {
+ }
+
+ }
+
+ shadowServer {
+
+ host = "httpbin.org"
+ port = 80
+
+ query-param-overrides {
+ test = ["hello"]
+ }
+
+ form-param-overrides {
+ test2 = ["world"]
+ }
+
+ }
+}
+
+spray.can.server {
+ server-header = shadow-server/${shadow.version}
+ request-timeout = 15s
+ stats-support = true
+}
+
+spray.can.client {
+ user-agent-header = shadow/${shadow.version}
+}
View
@@ -2,40 +2,53 @@ import sbt._
import sbt.Keys._
import sbtassembly.Plugin._
import AssemblyKeys._
+import sbtrelease.ReleaseStep
import spray.revolver.RevolverPlugin._
+import sbtrelease.ReleaseStateTransformations._
+import sbtrelease.ReleasePlugin._
+import sbtrelease.ReleasePlugin.ReleaseKeys._
object ShadowBuild extends Build {
lazy val shadow = Project(
id = "shadow",
base = file("."),
- settings = Project.defaultSettings ++ Revolver.settings ++ assemblySettings ++ Seq(
+ settings = Project.defaultSettings ++ releaseSettings ++ Revolver.settings ++ assemblySettings ++ Seq(
name := "shadow",
organization := "com.twilio",
scalaVersion := "2.10.0",
mainClass in assembly := Some("com.twilio.shadow.Boot"),
- assembleArtifact in packageScala := true, //exclude scala library from assembly artifact
+ assembleArtifact in packageScala := true, //exclude scala library from assembly artifact
test in assembly := {}, //disable running test when creating assembly aritifact
assemblyCacheOutput in assembly := true,
+
libraryDependencies ++= List(
-
- "io.spray" % "spray-can" % "1.1-M7",
- "io.spray" % "spray-routing" % "1.1-M7",
- "io.spray" % "spray-testkit" % "1.1-M7",
- "com.typesafe.akka" %% "akka-actor" % "2.1.0",
- "org.json4s" %% "json4s-native" % "3.2.4",
- "org.json4s" %% "json4s-jackson"% "3.2.4",
- "com.codahale.metrics" % "metrics-core" % "3.0.0-BETA2",
- "com.codahale.metrics" % "metrics-json" % "3.0.0-BETA2",
- // test
- "org.scalatest" %% "scalatest" % "2.0.M5b" % "test",
- "com.xebialabs.restito" % "restito" % "0.4-alpha-2" % "test",
- "com.typesafe.akka" %% "akka-testkit" % "2.1.0" % "test"
+ "io.spray" % "spray-can" % "1.1-M7",
+ "io.spray" % "spray-routing" % "1.1-M7",
+ "io.spray" % "spray-testkit" % "1.1-M7",
+ "com.typesafe.akka" %% "akka-actor" % "2.1.0",
+ "org.json4s" %% "json4s-native" % "3.2.4",
+ "org.json4s" %% "json4s-jackson" % "3.2.4",
+ "com.codahale.metrics" % "metrics-core" % "3.0.0-BETA2",
+ "com.codahale.metrics" % "metrics-json" % "3.0.0-BETA2",
+
+ // log generation
+ "org.slf4j" % "slf4j-api" % "1.7.5",
+ "ch.qos.logback" % "logback-classic" % "1.0.13",
+
+ // test
+ "org.scalatest" %% "scalatest" % "2.0.M5b" % "test",
+ "com.xebialabs.restito" % "restito" % "0.4-alpha-2" % "test",
+ "com.typesafe.akka" %% "akka-testkit" % "2.1.0" % "test"
),
compileOrder := CompileOrder.Mixed,
- mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) => { case x => old(x) }},
+ mergeStrategy in assembly <<= (mergeStrategy in assembly) {
+ (old) => {
+ case x => old(x)
+ }
+ },
classpathTypes ~= (_ + "orbit"),
resolvers ++= List(
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
View
@@ -1 +1 @@
-sbt.version=0.12.1
+sbt.version=0.12.2
View
@@ -2,10 +2,9 @@ addSbtPlugin("io.spray" % "sbt-revolver" % "0.6.2")
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
-addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.3.0-SNAPSHOT")
-
-resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.6")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.7")
+
Oops, something went wrong.

0 comments on commit c2b6cdd

Please sign in to comment.