简体   繁体   中英

grails different config files for multiple server

currently I'm trying to setup config files for each ip my application is running.

Here is a part of my Config.groovy :

grails.config.locations = [
    "file:web-app/WEB-INF/conf/${InetAddress.getLocalHost().getHostAddress()}.groovy",
    "file:web-app/WEB-INF/conf/dataSource/${InetAddress.getLocalHost().getHostAddress()}.properties"
]

that works locally but on tomcat not because there is no folder web-app , so I added:

"file:WEB-INF/conf/${InetAddress.getLocalHost().getHostAddress()}.groovy",
"file:WEB-INF/conf/dataSource/${InetAddress.getLocalHost().getHostAddress()}.properties"

But that still doesn't work.

How can I get the tomcat to load the config files correctly?

When starting tomcat in your catalina opts :

Configuration location for external config - called in Config.groovy

* JAVA_OPTS="$JAVA_OPTS -DCONFIGLOC=conf/"
* now it will look for {tomcatbase}/conf/{appname}/{appname}Config.groovy

Then in your Config.groovy :

if (System.getProperty('CONFIGLOC')) {
    externalConfigPath='file:'+System.getProperty('CONFIGLOC')+File.separator+appName+File.separator
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM