tyrcho / openshift-cartridge-play2

Play2 In OpenShift as a cartridge
https://github.com/tyrcho/openshift-cartridge-play2
37 stars 42 forks source link

[Q] How to add configuration options at runtime #5

Closed cedricziel closed 10 years ago

cedricziel commented 10 years ago

Thx for your efforts so far-I really appreciate it, as we use it as base to run play on a Origin instance.

My Question is: How would I add configuration settings at runtime to my application?

As far as I see, there are only 2 possibilities by now:

The first is obviously not that good (at least that's how I see it), as you have to put all into the config-file. (And it doesnt allow for $_JAVA_OPTS). The second option requires root access, as the control script isnt writable for the cartridge owner (which is a good thing in theory).

... How could I contribute to make this more configurable? Or is there a way I didnt see so far?

Thank you in advance for your answer!

cedricziel commented 10 years ago

Alright... I found a mix of both which is appropriate for my needs:

1.) The play command appends _JAVA_OPTIONS to each commands it runs. So setting environment variable _JAVA_OPTIONS => -Xmx=512M removes the build failure on smaller gears without having to modify anything 2.) Setting PLAY_OPTS as well appends a string to each of the commands so I can mix and match different environment variables with an appropriate openshift.conf file.

Maybe Captain Obvious in the house, but I didnt know about it ;)

Thx again for your efforts!

tyrcho commented 10 years ago

Good to know you are using this cartridge :-) I think the 2 solutions you suggest are completely in line with the Openshift and Play approach.

tyrcho commented 10 years ago

have also a look at this commit : a6098f31be137b, now it seems to work out of the box even on a small gear with the _JAVA_OPTIONS set. (you still need to wait about 5 mins for the initial build to complete)

cedricziel commented 10 years ago

I basically copied my answer about from my own SO answer. http://stackoverflow.com/a/23131088/1494697

But anyways: Good to know for starters ;-)

While you're at it: can you pull in the fork with 2.2.2 compatibility?