DavidJ
DavidJ

Reputation: 4567

How can Grails load config external to WAR via HTTP?

I've seen questions and answers about how to specify external .groovy and .properties files for Grails config that are outside of the WAR file using grails.config.locations, but we need external config that isn't on the server on which the container (Tomcat) is running. (It does have a local FS, but it is not persistient and is identical for all deployment environments - hence the need to override it external to the WAR, container and server).

So, can I use http: URLs for grails.config.locations ?

Upvotes: 3

Views: 862

Answers (2)

DavidJ
DavidJ

Reputation: 4567

Yes. The following works:

Add this in Config.groovy and pass PARAM1 using -D to the JVM to specify the external URL for the config file.

grails.config.locations = ["url:" + System.properties["PARAM1"]]

Upvotes: 4

chrislatimer
chrislatimer

Reputation: 3560

I am not aware of any built in functionality that would allow you to specify URL for grails.config. However, it seems like something that you could implement yourself:

  • define your URL(s) that you want to use to d/l the Congif.groovy file that is included in your WAR
  • in that same Config.groovy script, write code to download the file to a specific location on your server's file system (see this article)
  • set your grails.config.locations to point to the file system location that you wrote the Config.groovy file to.

I haven't tried it but seems like it would work.

Upvotes: 1

Related Questions