Created
June 6, 2015 17:17
-
-
Save samsondav/616627066d593a1275cc to your computer and use it in GitHub Desktop.
Extract DATABASE_URL environment variable for app running inside Apache Tomcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import [javax.naming Context InitialContext]) | |
(def development-db-string "postgresql://localhost:5432/foobar_db") | |
(def db-uri | |
(atom | |
(try | |
(. (. (InitialContext.) lookup "java:comp/env") lookup "DATABASE_URL") ; will pull environment variables from a Tomcat server | |
(catch javax.naming.NoInitialContextException e | |
(or | |
(System/getenv "DATABASE_URL") | |
development-db-string))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment