Found the reason: "." character is not allowed in env property names on
linux, so this would only work on windows
Cheers
On Saturday, March 5, 2016 at 2:05:18 PM UTC+1, Pierre wrote:
>
> Hello,
>
> Here is the answer to my own question:
>
> val default = ConfigFactory.parseString(
> """
> |a {
> | b = "foo"
> }
> """.stripMargin)
>
> import collection.JavaConversions._
> val conf = ConfigFactory.parseMap(System.getenv(), "env
> variables").withFallback(ConfigFactory.load())
>
> // will display the content of env variable a.b if set, foo otherwise
> println(conf.getString("a.b"))
>
> The issue was that ConfigFactory.systemEnvironment() does not, for some
> reason, do any parsing, so "a.b=x" is not parsed as a { b = x }.
>
> Note that ConfigFactory.systemProperties() *does* parse the properties,
> which explains the different result. I can't explain the inconsistency and
> this looks like a bug to me.
>
> Thanks for nothing ;-)
>
> Pierre
>
>
>
> On Thursday, March 3, 2016 at 7:00:01 PM UTC+1, Pierre wrote:
>>
>> Hello,
>>
>> I am using amazon beanstalk, which allows me to define app parameters
>> using system environment variables.
>>
>> If there was only a few well defined variables I would want to override,
>> the following would be fine:
>>
>> http {
>> port = 8080
>> port = ${?HTTP_PORT}
>> }
>>
>>
>> But there are a lot of parameters to override, and moreover I don't want
>> to have to explicitely define them beforehand.
>>
>> What I'd like would be to use system environment variables just like java
>> properties, meaning to have:
>> set spray.can.server.registration-timeout=5s
>> java -jar application.jar
>> work exactly like:
>> java -Dspray.can.server.registration-timeout=5s -jar application.jar
>>
>> I tried the following:
>>
>> val default = ConfigFactory.parseString(
>> """a {
>> | b = "foo"
>> }
>> """.stripMargin)
>>
>> val conf = ConfigFactory.systemEnvironment().withFallback(default)
>>
>> println(conf.getString("a.b"))
>>
>>
>> which kept printing "foo" even if I defined the environment variable a.b
>> to "bar". I think it doesn't work because withFallback won't override
>> values that are already defined.
>>
>> Do you guys have any idea on how to solve this?
>>
>> Thanks,
>>
>> Pierre
>>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.