5

I followed the instructions here https://developer.cloudbees.com/bin/view/RUN/Playframework and can deploy. But it only uses the application.conf.

My app ID is "mrm" so I created a "mrm.conf" in the conf directory.

Then I tried "play cloudbees-deploy-config mrm", but after deploying I get this error message:

[success] Total time: 110 s, completed Mar 15, 2013 9:08:36 PM
[error] Not a valid command: mrm (similar: run)
[error] Expected '/'
[error] Expected ':'
[error] Not a valid key: mrm (similar: run)
[error] mrm

And the deployment is still using the application.conf

Then I ran play, and entered: "cloudbees-deploy-config mrm" I got no error, but this way also deployed with application.conf

My "mrm.conf" contains this:

include "application.conf"
cloudbees.applicationId=mrm

I tried following the instructions as described on this pull-request: https://github.com/CloudBees-community/sbt-cloudbees-play-plugin/pull/1

According to the play help it should be possible like this:

cloudbees-deploy-config

  Deploy a configuration of your app to a Run@Cloud app id. Arguments are:
  (1) the base name of a conf file in your project's conf directory, defaulting to     "application"/
  (2) Optional. The application id to which this configuration should deploy. You can omit this
      arg if you have either set cloudbees.applicationId in the config file from the first
      arg or have set the project ID in your PlayProject.

  Example usage: `> cloudbees-deploy-config live`, where live.conf exists in the project's conf/
  directory and contains a key cloudbees.applicationId.

Any tips of what I could be doing wrong? I need it to be using the mrm.conf on the cloudbees deployment...

ANSWER:

play "cloudbees-deploy-config mrm"

UPDATE: just posted a summary of the solution to my Blog: http://www.poornerd.com/2013/04/08/how-deploy-play-framework-apps-with-different-configurations-to-cloudbees/

Brian Porter
  • 529
  • 3
  • 19
  • Why can't you use application.conf ? – biesior Mar 15 '13 at 21:37
  • I can't use the same conf because I have different settings. I also need a develop and live conf file for cloudbees as well well as for my local development. – Brian Porter Mar 16 '13 at 19:38
  • So as I suggest - use alternative conf for local development(s) – biesior Mar 16 '13 at 19:47
  • I could use an alternative conf for local dev, but I still need 2 different ones for 2 different configurations on cloudbees. – Brian Porter Mar 16 '13 at 19:50
  • That's the point, where I can't help you so... sorry no cloudbees experience, anyway accent it in your question, I hope, that somebody finally will give you proper answer. – biesior Mar 16 '13 at 19:52
  • If I start play, then enter "cloudbees-deploy-config mrm", then it deploys with the mrm.conf – Brian Porter Mar 16 '13 at 20:00

3 Answers3

5

How to tune the configuration for apps/frameworks on CloudBees will vary from framework-to-framework. The basic technique you need to use is:

  1. Figure out how you would tell your app to load this alternate config file when running locally
  2. Figure out how to make CloudBees do the equivalent when launching your application

Loading an Alternative Play Configuration File

Based on the Configuration or ProductionConfiguration docs on the Play2 site, it looks like you can specify a -Dconfig.resource=CONF_FILENAME system property to tell Play2 to load your alternative configuration:

Using -Dconfig.resource

It will search for an alternative configuration file in the application classpath (you usually provide these alternative configuration files into your application conf/ directory before packaging).

 $ start -Dconfig.resource=prod.conf

Based on this, we now know HOW to tell your runtime framework (Play) to load an alternate configuration file. Next, we need to figure out make CloudBees do the same.

Setting System Properties on CloudBees

The CloudBees SDK includes command line options for setting configuration parameters for your app that will be injected as system properties (for JVM-based apps) during startup. This can be done by specifying a -Pname=value option on the app:deploy command line or you can use the config:set command instead.

Since you are using the an SBT plugin to deploy your app (which may not support this feature), it would probably be easiest to use the SDK's config:set command:

bees config:set -a APPID config.resource=mrm.conf

Note: you'll need to restart your app for this config param to be applied

If I understand the Play2 docs correctly, this should cause Play to load the configuration file in conf/mrm.conf.

A Simpler Solution? - Just override the key

Based on your example, I noticed that you seem to be trying to only override the value of a specific configuration key in your default application.conf file...

Looking at the Play ProductionConfiguration docs, it seems like overriding the entire config file may be overkill, and that you could instead simply specify the value you want to override using a system property. The CloudBees SDK config:set command is designed exactly for this use-case and provides an easy way for you to inject custom app parameters. Java-based stacks on CloudBees will inject these parameters as System Properties, which means they should be picked up automatically by your Play app.

Based on the example override in your mrm.conf file, the following should work:

bees config:set -a APPID cloudbees.applicationId=mrm

If this works properly for you, I'll add some of this info back to the CloudBees Play docs.

swashbuck1r
  • 378
  • 1
  • 3
  • Just updated to cloudbees SDK 0.7.0, but it still does not recognize "config:set" `bees help config:set CloudBees SDK version: 0.7.0 Type 'bees help ' for help on a specific subcommand.` – Brian Porter Mar 28 '13 at 18:34
  • Also, If I add the applicationId in the Build.scala like this it does not use the similarly named conf file. `.settings( CloudBees.applicationId := Some("mrm") )` – Brian Porter Mar 28 '13 at 18:46
  • You wrote "If I understand the Play2 docs correctly, this should cause Play to load the configuration file in conf/mrm.conf." -> that is what I understood, too. – Brian Porter Mar 28 '13 at 18:49
  • Where are you getting that SDK from? The latest version is 1.3.1. Please re-download from http://developer.cloudbees.com/bin/view/RUN/BeesSDK – swashbuck1r Mar 28 '13 at 19:05
  • ok, I got the newest SDK - I had to `bees config:set -a APPID config.resource=mrm.conf`, then I could use `play cloudbees-deploy`but this is also only a partial solution, as I would need to switch back and forth between each project and test and production. – Brian Porter Mar 28 '13 at 20:12
  • based on the docs, I would have expected that this would work (which Is what I would really like to do): ` play cloudbees-deploy-config mrm` – Brian Porter Mar 28 '13 at 20:14
  • I don't understand what it means that you would need to switch back and forth. You can set the approprite config.resource param for each application. Anyhow, it sounds like you want to use SBT and have a bug or feature request to report against the CloudBees SBT plugin. I'd suggest opening a ticket against that project on github [https://github.com/CloudBees-community/sbt-cloudbees-play-plugin/issues] along with a clear descrpition of what you are trying to accomplish. – swashbuck1r Mar 28 '13 at 20:38
  • play "cloudbees-deploy-config mrm" should work, at least it does when I use sbt directly. – Ivan Meredith Mar 28 '13 at 21:17
  • @IvanMeredith you're the man! It was those quotes around "cloudbees-deploy-config mrm" (including the conf/appID) that did the trick. I could never get it to recognize the additional parameter. So now I was able to just type this: `play "cloudbees-deploy-config mrm"`` – Brian Porter Mar 28 '13 at 22:40
  • @swashbuck1r can you update the part about using the quotes in conjunction with the cloudbees-deploy-config ? There is no example on that docs page which shows deploying with a specific conf. – Brian Porter Mar 28 '13 at 22:45
  • I'm glad I could spend all that time writing my answer, only to have Ivan say, "did you add quotes?". :) I'm happy you have an answer now. I updated the wiki doc. – swashbuck1r Mar 28 '13 at 23:16
0

I'd suggest reversal situation: for live application place all configs required by CloudBees in application.conf so you will not need to override the config file.

On local machine create something like local_conf.conf and there 'deactivate' config params specific for CloudBees only. Additionaly you can write one-line bash script on local env, for running application with additional config (so you won't need to use -Dconfig.file-..." everytime.

biesior
  • 55,576
  • 10
  • 125
  • 182
0

This is only a partial solution but:

If I start play, then enter "cloudbees-deploy-config mrm", then it deploys with the mrm.conf

Brian Porter
  • 529
  • 3
  • 19
  • I still can't figure out how to enter "play cloudbees-deploy-config mrm" from my shell prompt. I don't really want to have to start play first then enter the second part each time. Either there is a bug - or I am not passing the parameter mrm properly. – Brian Porter Mar 18 '13 at 13:26
  • @IvanMeredith thanks, yes it those quotes were what I was missing! – Brian Porter Mar 28 '13 at 22:43