Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Application config

mlist edited this page Mar 14, 2013 · 1 revision

##Basic Configuration OLF will work without any further configuration. However, if you would like to change the default behavior, e.g. by using another database back-end, you should follow this guide.

Instead of changing the configuration for OLF within the project itself we chose an external variant by facilitating system variables. In other words: You can have a separate configuration file for each machine that is running OLF and you can also easily exchange config files to test different deployment settings. You should start by creating an an empty groovy file of arbitrary name (w.l.o.g. called openlabframework.groovy here) in a location of your choice.

The file should look similar to this one:

//disable the CAS server support for single sign on
grails.plugins.springsecurity.cas.active = false

//This is where OLF will store uploaded files
openlab.upload.dir = "/tomcat/upload/"

//This is where OLF keeps temporary files, e.g. when it creates content on the fly
openlab.temp.dir = "/tomcat/temp/"

//optional name for the database
openlab.database.name='MS-SQL-DB'

//you need to define your absolute address if you want to access OLF from a different computer
grails.serverURL = "http://192.168.1.1:8080/OpenLabFramework"

//this is where you configure database access
dataSource {
  //Access Microsoft SQL Server using JTDS driver (included)
  driverClassName = 'net.sourceforge.jtds.jdbc.Driver' 
  url = 'jdbc:jtds:sqlserver://127.0.0.1:1433;databaseName=OpenLabFramework_DB'
    //Access MySQL database instead
    //driverClassName = 'com.mysql.jdbc.Driver'    
    //url='jdbc:mysql://localhost:3306/olf_prod?useUnicode=yes&characterEncoding=UTF-8&autoreconnect=true'
    //dataSource.dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
  username = 'dbuser'
  password = 'changeme'
  dbCreate = 'update' //can also be create or drop for development purposes
  pooled = true //allow pooled connections
  //further hibernate properties for the database connection, e.g. keep connection alive
  properties {
      maxActive = -1
      minEvictableIdleTimeMillis=1800000
      timeBetweenEvictionRunsMillis=1800000
      numTestsPerEvictionRun=3
      testOnBorrow=true
      testWhileIdle=true
      testOnReturn=true
      validationQuery="SELECT 1"
  }
} 

##Setting the Environment Variable Now you will have to make OLF aware of this configuration file by specifying a system environment variable called OPENLABFRAMEWORK_CONFIG to point at this file. This has been tested under both, Windows XP, Windows 7 and different flavors of linux. Watch the console output when starting OLF. It will let you know whether it found your file or not.

##Different Environments If you are a software developer you will be interested in using different environments, e.g. for development, testing and production. This can easily done like this:

// set per-environment config
environments {
    development {

    }
    production {

    }
    test {

    }
    standalone {

    }
}

Note that development, production and test are environments that change the behaviour of grails. In the test environment unit and integration tests will be executed on start-up. In development code changes will be recognized dynamically at run-time, which basically means that as a software developer you don't have to restart the application every time you want to test a change.

##Single Sign On with CAS and Alternatives In case you want to activate the CAS plug-in you should add something like this to your config:

//CAS configuration for single sign on
grails.plugins.springsecurity.cas.active = true
grails.plugins.springsecurity.cas.loginUri = '/login'
grails.plugins.springsecurity.cas.serviceUrl = grails.serverURL + '/j_spring_cas_security_check'
grails.plugins.springsecurity.cas.serverUrlPrefix = 'https://your.cas.server.com'
grails.plugins.springsecurity.cas.proxyCallbackUrl = grails.serverURL + '/secure/receptor'
grails.plugins.springsecurity.cas.proxyReceptorUrl = '/secure/receptor'
grails.plugins.springsecurity.logout.afterLogoutUrl = 'https://your.cas.server.com/logout?url=' + grails.serverURL

Also note that SpringSecurity offers many more plug-ins, e.g. for authentication via OpenID, facebook, ...

Clone this wiki locally