1

I would like to have a pair ofdb-specmaps with my database configuration for development and production.

But I can't find an easy way to detect the current execution environment. Need something like (defn db-spec [] (if (is-dev?) { dev-spec-here } { prod-spec-here })).

Maybe it can detect the current lein profile. No matter how I ask to google. Can't find how.

2
  • So... you're trying to come up with a suitable implementation for the is-dev? function to give your desired behavior? If so, I think you need to give a little more details about how this application is intended to be deployed and run. Commented Dec 17, 2012 at 18:07
  • Hi @Alex basically if you're in the repl. Anyway I found the solution using java system properties. See stackoverflow.com/a/13921837/466250 Commented Dec 18, 2012 at 3:02

2 Answers 2

1

I'm fond of using environment variables for this (which can be set system wide for example in /etc/profile amongst other places). others prefer to pass a -D definition to the JVM

Sign up to request clarification or add additional context in comments.

1 Comment

Great. The -D thing was perfect. At lein dev profile added :jvm-opts ["-Ddev=true"] then I ask for (System/getProperty "dev"). If nil then use production configuration. Use development config otherwise
0

your code is okay, detect it depend your environment, like hostname, IP arrdress, global variable etc.

1 Comment

can you provide more details?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.