Grails enviroment variables

From Blue-IT.org Wiki

Revision as of 17:19, 12 January 2012 by Apos (talk | contribs) (Created page with "== Custom grails environment === === DataSource.groovy === myEnv { dataSource { //dbCreate = "create" // one of 'create', 'create-drop','update' ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Custom grails environment =

DataSource.groovy

myEnv {
        dataSource {
            //dbCreate = "create" // one of 'create', 'create-drop','update'
            pooled = true
            dbCreate = "create-drop"
//            dbCreate = "update"
            url = "jdbc:mysql://127.0.0.1:3306/mydb"
            driverClassName = "com.mysql.jdbc.Driver"
            dialect = org.hibernate.dialect.MySQL5InnoDBDialect
            username = "anUser"
            password = "mypass"
            
            properties {
                minEvictableIdleTimeMillis=1800000
                timeBetweenEvictionRunsMillis=1800000
                numTestsPerEvictionRun=3
                testOnBorrow=true
                testWhileIdle=true
                testOnReturn=true

                validationQuery="SELECT 1"
            }
        
    }

Config.groovy

// set per-environment serverURL stem for creating absolute links
environments {

    myEnv {
        //grails.app.context = "/"
        roadrunner.websiteUrl = "http://mysite"
        grails.serverURL = "http://mysite"
        grails.tenantDomain = "mysite"
        grails.domain = "mysite"
        jqueryUi.minified = false;
        jqueryUi.cdn = 'googlecode'
    }


And don't forget log4j

touch /var/log/tomcat6/myapp_stacktrace.log
chown tomcat6:tomcat6 /var/log/tomcat6/myapp_stacktrace.log

// log4j configuration
log4j = {
    // Example of changing the log pattern for the default console
    // appender:
    //
    appenders {
        console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
    }

    environments {
        myEnv {
                  log4j.appender.'errors.File'="/var/log/tomcat6/myapp_stacktrace.log"
                  
                  error 'org.whatever',
                        'org.other'
                        
                  warn  'org.another'
        }