Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I specify which application.conf to user when deploying on cloudbees

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/

like image 634
Brian Porter Avatar asked Mar 15 '13 20:03

Brian Porter


1 Answers

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.

like image 188
swashbuck1r Avatar answered Nov 19 '22 01:11

swashbuck1r