§Developer quick start

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:

§Prerequisites

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.

§Signaling application state

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 build.sbt:

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"

§Creating application bundle

sbt-conductr-sandbox is an sbt plugin to easily manage your application inside ConductR. This plugin includes sbt-bundle and sbt-conductr.

  1. Add sbt-conductr-sandbox to the project/plugins.sbt:
    addSbtPlugin("com.typesafe.conductr" % "sbt-conductr-sandbox" % "1.2.1")
    
  2. Specify sbt-bundle keys in the build.sbt:
    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")
    
  3. Reload the sbt session:
    reload
    
  4. Create the bundle inside you sbt session with:
    bundle:dist
    

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.

§Starting ConductR cluster

Now we can go ahead an start the ConductR cluster locally.

  1. Configure the build.sbt as described by the ConductR download page.

  2. Reload the sbt session:

    reload
    
  3. 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...
    
  4. Access ConductR visualizer at http://{docker-host-ip}:9909 where docker-host-ip is 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.

§Deploying application bundle to ConductR

  1. Load your application bundle to ConductR:
    conduct load <HIT THE TAB KEY AND THEN RETURN>
    
  2. Run bundle on one node:
    conduct run my-app
    
  3. 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.

Next: Signaling application state