Grails Web Site
Groovy JavaScript CSS HTML Java Batchfile Shell
Switch branches/tags
www-4.20 www-4.15 www-4.12 v2.3.1 v2.1.1 v2.1.0 v2.0.6 v2.0.4 v2.0.3 v2.0.2 v1.2.21 v1.2.20 v1.2.19 v1.2.18 v1.2.17 v1.2.14 v1.2.13 v1.2.12 v1.2.11 v1.2.10 v1.2.8 v1.2.7 v1.2.6 v1.2.5 v1.2.3 v1.2.2 v1.2.1 v1.2 v1.1.3 v1.1.2 v1.1.1 v1.1 v1.0.9 v1.0.8 v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 prod_2018_02_03_activate prod_2017_10_04_active prod_2017_03_22_10_00_activate prod_2017_03_22_activate prod_2017_02_15_activate prod_2016-10-06_activate prod_2016-07-08_activate prod_2016-02-29_activate prod_2015-12-22_activate prod_2015-12-03_activate prod_2015-04-22_activate prod_2015-04-21_3_activate prod_2015-04-21_2_activate prod_2015-04-21_activate prod_2015-04-20_activate prod_2015-04-19_activate prod_2015-04-02_activate prod_2015-04-01_2_activate prod_2015-04-01_activate prod_2015-03-25_activate prod_2015-03-19_activate prod_2015-03-18_2_activate prod_2015-03-18_activate prod_2015-03-11_activate prod_2015-03-10_activate prod_2015-03-07_activate prod_2015-03-06_2_activate prod_2015-03-06_activate prod_2015-03-05_activate prod_2015-03-04_activate prod_2015-02-27_activate prod_2015-02-26_6_activate prod_2015-02-26_5_activate prod_2015-02-26_4_activate prod_2015-02-26_3_activate prod_2015-02-26_2_activate prod_2015-02-26_activate prod_2015-02-25_3_activate prod_2015-02-25_2_activate prod_2015-02-25_activate prod_2015-02-24_2_activate prod_2015-02-24_activate prod_2015-02-20_3 prod_2015-02-20_2 prod_2015-02-20 prod_2015-02-19_5 prod_2015-02-19_4 prod_2015-02-19_3 prod_2015-02-19_2 prod_2015-02-19 prod_2015-02-18_5 prod_2015-02-18_4 prod_2015-02-18_3 prod_2015-02-18_2 prod_2015-02-18 prod_2015-02-17 prod_2015-02-14_3 prod_2015-02-14_2 prod_2015-02-14 beta-4.29 beta-4.25
Nothing to show
Clone or download
Failed to load latest commit information.
cf-deployment add sendgrid configuration example Feb 16, 2015
fixtures Remove screencasts Feb 9, 2017
grails-app Fix 301 wiki/GrailsDevFirms/version to support.html Feb 3, 2018
inline-plugins add inline plugin that removes cookie-config element from web.xml for… Feb 24, 2015
lib Update gdoc-engine dependency. Nov 4, 2011
migrations Remove changelogs Feb 9, 2017
mysql mysql scripts for creating test database and user for it Jan 22, 2015
src Plugin Redirect Feb 9, 2017
test/unit Merge pull request #71 from grails-samples/remove_old_domains Feb 9, 2017
tomcat-deployment Use ~/tmp instead of ~/.grails-static-website Feb 6, 2017
travis fix crypt_stream script on linux Apr 21, 2015
web-app Remove Build with Grails Footer Feb 9, 2017
wrapper upgrade to Grails 2.5.0 Apr 1, 2015
.gitignore .slcache to gitignore Feb 9, 2017
.travis.yml use jdk8 for building Apr 21, 2015 add documentation about production deployment Feb 25, 2015 upgrade to Grails 2.5.0 Apr 1, 2015
cf-deploy-war.tar.gz.gpg update crypted config Apr 21, 2015
cf-deploy.gradle Revert "Revert "Try deploy with the regular build pack"" Feb 6, 2017 fix staging/development environment deployment Apr 1, 2015 add script for showing stacktrace.log on CloudFoundry server Feb 24, 2015 scale to 2 instances in production environment. Mar 31, 2015
grailsw upgrade to Grails 2.5.0 Apr 1, 2015
grailsw.bat upgrade to Grails 2.5.0 Apr 1, 2015 fix staging/development environment deployment Apr 1, 2015 deploy to Pivotal WS CloudFoundry after successful build Feb 14, 2015 add config for CF development space Feb 14, 2015

Build Status (including Wiki)

This is the Grails project for Please fork and submit pull requests for any changes made, and don't forget to use the appropriate version of Grails as specified in Alternatively, you can use the Grails wrapper script in the root of the project, grailsw.

Quick Start

Once you have cloned the repository, you can immediately try it out with

./grailsw compile
./grailsw -Dreindex=1 run-app

Ignore the warnings about not finding the site-config.groovy files - they are expected.

The above command starts the application in the development environment with some sample data. Note that the application depends on quite a few plugins so you will have to wait for those to be downloaded and installed. Also be aware that the plugins are installed in a sub-directory of the project called plugins.

The default development and test environments are configured to use an in-memory H2 database, as you can see if you take a look at the DataSource.groovy file. The sample data comes from some fixtures that are loaded by BootStrap.groovy. If you want to add or otherwise modify the sample data, simply modify the fixtures! Note that these fixtures require the Fixtures plugin.

This setup is fine for most development, but if you want to modify the data model in any way you will need to understand how the application runs in production.

Production Environment

The production environment uses a MySQL database, for which you need to configure the data source. The easiest way to do this is to create a site-config.groovy file in the root of the project that contains the data source configuration for MySQL:

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    url = "jdbc:mysql://localhost/grails"
    username = "root"
    password = ""
    dbCreate = null

You don't have to use the credentials and database name specified above, but make sure that the database you specify exists because it won't be created automatically! Also note that the dbCreate setting is important as we want to disable Hibernate's automatic schema creation.

You'll then want to make sure the database migration plugin's autorun feature is enabled in your 'site-config.groovy' file so that the necessary tables are created in your database:

grails.plugin.databasemigration.updateOnStart = true

With the data source configured you can just start the application:

./grailsw -Dinitial.admin.password=changeit -Dload.fixtures=true prod run-app

We start it in the production environment because that's required for the database migrations to run. If you run without the 'prod', your database will be empty and the application will fail to start. Remember, we're not using Hibernate's automatic schema creation.

Once you have started the application using the above command line, you can subsequently run it using the much simpler

./grailsw run-app


./grailsw prod run-app

Since the data source in site-config.groovy isn't tied to a particular environment, both development and production will run against the configured MySQL database.

Changing the Domain Model

If you make any changes to the domain model, such as adding or removing domain classes or domain class properties, then you will have to create an associated changelog. This application uses the Database Migration plugin and its migration scripts are kept under the migrations directory. The policy is to have a separate changelog file for each new version of the application, and each commit to a changelog should have its own changeSet definition (or more than one). Any changes to a changelog should be committed with the corresponding domain model changes!

More to come...

Testing plugin publishing locally

Setting up local test environment

Add these release plugin settings to ~/.grails/settings.groovy = "http://localhost:8080/plugin/" = "admin" = "changeit"

grails.project.repos.myRepo.url = "http://localhost:8080/plugins"
grails.project.repos.myRepo.type = "grailsCentral"
grails.project.repos.myRepo.username = "admin"
grails.project.repos.myRepo.password = "changeit"
grails.project.repos.myRepo.portal = "my"

Download Artifactory zip from and unzip it to some location. Modify tomcat/conf/server.xml file before starting Artifactory. Change the port from 8081 to 8085 .

        <Connector port="8085"/>

Then start Artifactory.

./bin/ start

Add a file site-config.groovy to the grails-website directory with this content:

beans {
     pluginDeployService {
         releaseUrl = "http://localhost:8085/artifactory/plugins-release-local/org/grails/plugins"
         snapshotUrl = "http://localhost:8085/artifactory/plugins-snapshot-local/org/grails/plugins"
         deployUsername = "admin"
         deployPassword = "password"

Testing plugin publishing

Start grails-website with run-app: grails run-app

Start artifactory if it's not already running: ARTIFACTORY_INSTALL_DIR/bin/ start

Publish some plugin (f.e. mail) that already exists in the repository (so that it's already approved): grails publish-plugin --repository=myRepo --portal=my --stacktrace

Production deployments

Deploying to production

Production deployments are automated with Travis CI. Travis will deploy the app to production when a tag starting with "prod_" gets pushed to Github. Blue-Green deployment model is used to do zero-downtime upgrades. Currently there isn't any downtime, but the sessions aren't replicated so they are lost. By default the app will get deployed to the inactive node and that won't get activated by default. When the tag starting with "prod_" also ends with "_activate", the app will get activated when the app has started up successfully.

Here is an example of cf apps output for the current production environment.

Getting apps in org grails-org / space production as someuser@somedomain...

name                            requested state   instances   memory   disk   urls
plugins-grails-org-prod-blue    started           1/1         2G       1G,
plugins-grails-org-prod-green   started           1/1         2G       1G,,,,,,

"Activation" means in this case the process of switching the URL routes,, and links to point to the recently updated app. A script does this switching. Adding the parameter -Pprod will target the production environment.

If you decide to activate the recently deployed app manually, you can do it with this command: ./ -Pprod You should put your CloudFoundry username and password to the file


Production configuration

The file cf-deploy-war.tar.gz.gpg contains encrypted production and development environment configuration. The production config is in a file cf-deployment-production/WEB-INF/classes/site-config.groovy. and scripts are used to encrypt and decrypt these files. These scripts assume that the symmetric crypt key is in CF_FILES_CRYPT_KEY environment variable. The cipher used is symmetric key AES256 with gpg.