Login required
Download

Cloud Foundry Plugin

(3)
Author(s): graemerocher
Current Release: 0.1
Grails Version: 1.1 > *
Tags
grails install-plugin cloud-foundry
The Cloud Foundry plugin for Grails integrates Cloud Foundry's cloud deployment services to manage the running of Grails applications in the cloud from the command line.

Installation

First of all, you should have a Cloud Foundry account. If you do not currently have one, please go to www.cloudfoundry.com and sign up for one.

Next, you'll need to install the plugin. Execute the following from your application directory:

grails install-plugin cloud-foundry

If the above method does not work, you can download the plugin distribution from here and install:

grails install-plugin /path/to/downloaded/plugin/distrib

During the plugin installation, it will ask the following question:

Cloud Foundry requires MySQL to be configured appropriately. Do you want your
DataSource.groovy conigured automatically (will overwrite existing DataSource.groovy)? (y, n)

Enter 'y' if you plan on using a database for your application. Cloud Foundry will automatically provision a MySQL database to work with your application. Once the plugin has been installed, update grails-app/conf/CloudFoundry.groovy file with your Cloud Foundry account credentials.

Screencast

To see the Cloud Foundry Grails plugin in action, take a look at this screencast.

Quick Start

First, create your Grails application and install the Cloud Foundry as described above. Once you have finished the development of your application, build the WAR file:

grails war

The WAR file is what gets uploaded to Cloud Foundry and actually deployed. Run the following command:

grails cloud-foundry-deploy

That's it. Once the virtual instances can be started in the cloud, Cloud Foundry will provision the software stack and deploy your application in the application server. Then your Grails application will be available to your users to access. To find out the current status of the deployment (launched application), you can either log onto http:// www.cloudfoundry.com, or type the following command:

grails cloud-foundry-info

This will output the current status, health, and virtual machine instance information of your deployment.

Commands

grails cloud-foundry

The first and most basic command is grails cloud-foundry. This actually performs the next two commands, grails cloud-foundry-list-applications and grails cloud-foundry-list-deployments to give you an overview of the applications and deployments associated with your Cloud Foundry account.

grails cloud-foundry-list-applications

Returns a list of all applications you have uploaded to Cloud Foundry, including both Grails and non-Grails applications. Here is an example output:

Cloud Foundry Applications
------------------------------------------------
- Id: 922, Name: PetClinic, Deployed: Deployable, Region: us-east-1
- Id: 278, Name: Travel, Deployed: Deployable, Region: us-east-1
- Id: 474, Name: Library, Deployed: Deployed, Region: us-east-1

grails cloud-foundry-list-deployments

Returns a list of all deployments that are associated with your account, including deployments of other applications and both running/stopped deployments. Here is an example output:

Cloud Foundry Deployments
------------------------------------------------
- Id: 1181, Name: PetClinic, Application:PetClinic, State: STOPPED, Health: STOPPED
- Id: 1192, Name: Library, Application:library, State: LAUNCHED, Health: HEALTHY

grails cloud-foundry-upload

This command simply uploads the current Grails application to your Cloud Foundry account so that it is ready to deploy. It examines the WAR file to strip out any known standard JAR files so that the bundle can be minimized to expedite uploading. For a standard Grails application, this process should be extremely fast and is actually an advantage over using the web-based Cloud Foundry user-interface.

grails cloud-foundry-deploy

As described previously, this command will actually deploy your application to the cloud and make it accessible to others. However, the command actually wraps two steps into one. First of all, it uploads the application in the same way as grails cloud-foundry-upload. Secondly, it instructs Cloud Foundry to actually launch the application in a deployment. This is performed asynchronously. The application may not be ready yet until Cloud Foundry has fully started the virtual machine instances and finished provisioning the software.

grails cloud-foundry-info

This command will output the current status, health, and virtual machine instance information of your deployment. This information will help you determine if the deployment is ready for your end users. Here is an example output:

Cloud Foundry Deployment Details
---------------------------------
Id: 1391
Name: GrailsApp-0.1
State: LAUNCHED
Creation Time: 03-Nov-09 14:50:21
Health: HEALTHY
Instances:
- Id: 1787
- Public DNS: ec2-67-202-58-98.compute-1.amazonaws.com
- Home Page: http://path/to/your/app
---------------------------------

grails cloud-foundry-redeploy

This command assumes that you have already uploaded the version of the application that you want to run. It instructs Cloud Foundry to copy the latest application WAR file to the application server and restart it.

grails cloud-foundry-stop

This command stops the current running deployment.

grails cloud-foundry-delete-deployment

After a deployment has been stopped, its history remains available to you. If you no longer want to view the information, using this command will clear the deployment out of your history. Note: the command will fail if the deployment has not been stopped first.

grails cloud-foundry-delete-application

Similar to deleting a deployment, if an application is no longer running in a deployment, you can remove it from your Cloud Foundry account by using this command.

Note: this command requires an application identifier, which is the ID returned by grails cloud-foundry-list-applications command.

Source Code

You can obtain the Cloud Foundry plugin source code through Subversion.

svn co https://src.springsource.org/svn/cloudfoundry_plugins/grails/cloud-foundry