ConductR simplifies the deployment of applications with resilience and elasticity without disrupting the application development lifecycle. Developers continue to develop and test their applications as they normally would prior to deployment.
This guide describes how to setup and deploy a Play 2.4 Scala application on ConductR. In particular it describes how to:
- Signaling that application is started
- Creating application bundle
- Starting ConductR cluster
- Deploying application bundle to ConductR
The focus of this section is to get started quickly. The full documentation of these parts are described in these sections:
Docker is required so that you can run the ConductR cluster as if it were running on a number of machines in your network. You won’t need to understand much about Docker for ConductR other than installing it as described in its “Get Started” section. If you are on Windows or Mac then you will become familiar with
docker-machine which is a utility that controls a virtual machine for the purposes of running Docker.
sbt is our interactive build tool. Reading the getting started guide for sbt is recommended.
First let us setup the Play 2.4 application for ConductR. Your application should tell ConductR when it has completed its initialization and is ready for work. For a Play 2.4 application add these dependency to your
resolvers += "typesafe-releases" at "http://repo.typesafe.com/typesafe/maven-releases" libraryDependencies += "com.typesafe.conductr" %% "play24-conductr-bundle-lib" % "1.0.2"
Now you can add a guice module in the
application.conf. This module tells ConductR when your application has been started and therefore ready to start processing requests:
play.application.loader = "com.typesafe.conductr.bundlelib.play.ConductRApplicationLoader" play.modules.enabled += "com.typesafe.conductr.bundlelib.play.ConductRLifecycleModule"
addSbtPlugin("com.typesafe.conductr" % "sbt-conductr-sandbox" % "1.2.1")
sbt-bundlekeys in the
import ByteConversions._ BundleKeys.nrOfCpus := 1.0 BundleKeys.memory := 64.MiB BundleKeys.diskSpace := 10.MB BundleKeys.roles := Set("web") BundleKeys.endpoints := Map("my-app" -> Endpoint("http", services = Set(URI("http://:9000")))) javaOptions in Bundle ++= Seq("-Dhttp.address=$MY_APP_BIND_IP", "-Dhttp.port=$MY_APP_BIND_PORT")
- Reload the sbt session:
- Create the bundle inside you sbt session with:
The new bundle should be created in your
target/bundle directory. The
sbt-bundle effectively describe what resources are used by your application and are used to determine which machine they will run on in the ConductR cluster.
As you move through our documentation you will come across references to ConductR’s environment variables e.g.
MY_APP_BIND_PORT. Please refer to our documentation for information on the meaning of these environment variables should you need to.
Now we can go ahead an start the ConductR cluster locally.
build.sbtas described by the ConductR download page.
Reload the sbt session:
Start ConductR cluster with visualization feature:
[my-app] sandbox run --withFeatures visualization [info] Running ConductR... [info] Running container cond-0 exposing 192.168.59.103:9909...
- Access ConductR visualizer at
docker-host-ipis the host of your docker environment. For convenience, the url of the visualizer app is displayed in the sbt session, e.g. http://192.168.59.103:9909.
- Load your application bundle to ConductR:
conduct load <HIT THE TAB KEY AND THEN RETURN>
- Run bundle on one node:
conduct run my-app
Access your application at http://docker-host-ip:9000.
In the visualizer web interface you should see now two bundles running, the visualizer bundle itself and your application bundle.
That’s it! You now have ConductR running with the visualizer and your own application. Head over to the next chapters to learn in greater detail how to setup, configure and run your applications on ConductR.