Grails
From Stax
Note: Grails is a self-contained project environment with its own tools for performing project tasks like creating models, controllers and running applications. This self contained design does not use a standard WAR-file layout, so it can't use the standard stax create/run/deploy commands. Instead, the easiest way to work with Grails is to create and develop using the normal grails tools, and then export the grails application as a WAR file that can be deployed to the Stax Cloud using the stax app:deploy command.
Contents |
Initial setup
First, make sure you have installed [Grails 1.1.x]
Creating your Grails app
To create a grails app, specify the grails template when using the stax create command. This will create a standard grails directory structure where you can use your standard grails commands.
grails create-app [appname]
Note: by default, Grails is configured to use a local filesystem-based database which won't work in the Stax environment. Instead you should configure your application to use a Stax database URL (see Configuring Stax DataSources below)
Running your Grails app
To run your grails app, you need to use the standard grails run-app command.
grails run-app
Deploying your Grails app
Use the standard Grails war command to package your application as a standard WAR file.
grails war
Deploy the generated WAR file to Stax
stax app:deploy -a STAX_APPID [PATH_TO_WAR_FILE]
Configuring Stax DataSources
Note: to use Stax databases locally from your application, you first need to add the Stax SDK's appserver.jar file to your grails classpath. Alternatively, you can connect to your Stax database using the regular mysql driver.
DataSources used by Grails are defined in the grails-app/conf/DataSource.groovy file. If you follow the grails conventions, then you would want to create 3 Stax databases with the names (where STAX_DB is a base DB name of your choosing):
- STAX_DB (production database)
- STAX_DB-dev (development database)
- STAX_DB-test (test database)
To use these databases from your Grails app, you need to update the DataSource.groovy with datasources that look similar to the following (where STAX_DB is replaced with the base DB name you chose when creating the databases and the usernames/passwords are updated to the correct values):
dataSource {
pooled = true
driverClassName = "com.staxnet.jdbc.Driver"
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:stax://STAX_DB_NAME-dev"
username = "STAX_DB_USER-dev"
password = "STAX_DB_PASS"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:stax://STAX_DB_NAME-test"
username = "STAX_DB_USER-test"
password = "STAX_DB_PASS"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:stax://STAX_DB_NAME"
username = "STAX_DB_USER"
password = "STAX_DB_PASS"
}
}
}
