4 Deploying applications - Reference Documentation
Authors: Burt Beckwith
Version: 1.2.3
4 Deploying applications
Initial state
When you initially start you won't have any configured services or applications. Running the cf-services script should display something similar to this:$ grails cf-services============== System Services ==============+------------+---------+---------------------------------------+
| Service | Version | Description |
+------------+---------+---------------------------------------+
| postgresql | 9.0 | PostgreSQL database service (vFabric) |
| mysql | 5.1 | MySQL database service |
| redis | 2.2 | Redis key-value store service |
| mongodb | 1.8 | MongoDB NoSQL store |
| rabbitmq | 2.4 | RabbitMQ messaging service |
+------------+---------+---------------------------------------+=========== Provisioned Services ============None provisioned yet.
No applications available.
VMware's Cloud Application Platform For support visit support@cloudfoundry.comTarget: http://api.cloudfoundry.com (v0.999)User: your.email@yourserver.com Usage: Memory (0B of 2.0G total) Services (0 of 16 total) Apps (0 of 20 total)
Services
Before deploying your application, you'll probably need to configure at least one service, e.g. a MySQL, PostgreSQL, MongoDB, or Redis database. Use the cf-create-service script for that, e.g.$ grails cf-create-service mysqlService 'mysql-2f5fb76' provisioned.
$ grails cf-create-service redisService 'redis-364841f' provisioned.
============== System Services ==============+------------+---------+---------------------------------------+
| Service | Version | Description |
+------------+---------+---------------------------------------+
| postgresql | 9.0 | PostgreSQL database service (vFabric) |
| mysql | 5.1 | MySQL database service |
| redis | 2.2 | Redis key-value store service |
| mongodb | 1.8 | MongoDB NoSQL store |
| rabbitmq | 2.4 | RabbitMQ messaging service |
+------------+---------+---------------------------------------+=========== Provisioned Services ============+-----------------+---------+
| Name | Service |
+-----------------+---------+
| mysql-2f5fb76 | mysql |
| redis-364841f | redis |
+-----------------+---------+
$ grails cf-delete-service redis-364841fSuccessfully removed service: redis-364841f
Applications
The cf-push script creates an application. It deploys a war file and optionally binds one or more services, and has options to configure the allocated memory and associated URLs. By default it also starts the application but you can deploy it without starting if you want to perform configuration steps after creating the application.The default memory allocation is 512MB but this can be overridden with the--memory
parameter when running the script$ grails prod cf-push --memory=1G
Most scripts are not environment-specific but cf-push builds a war file, so be sure to specify the environment.A typical deploy command would be
$ grails prod cf-push --services=mysql-2f5fb76
prod cf-push --services=mysql-2f5fb76
Environment set to production Building war file [gspc] Compiling 13 GSP files for package … … Building WAR file … [copy] Copying 633 files to … … [propertyfile] Updating property file: … … [jar] Building jar: .../target/cf-temp-1299173015209.war … Done creating WAR ...target/cf-temp-1299173015209.warApplication Deployed URL: 'myappname.cloudfoundry.com'?Uploading Application Information. Trying to start Application: 'myappname'. ..................Application 'myappname' started.
+-------------+----+---------+----------------------------+---------------+ | Application | # | Health | URLs | Services | +-------------+----+---------+----------------------------+---------------+ | myappname | 1 | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76 | +-------------+----+---------+----------------------------+---------------+
grails prod cf-push --no-start
grails prod cf-push --warfile=target/myappname.war
Automatic binding and provisioning
You can also let the plugin discover required services for you. The plugin will determine that you probably need a MySQL or PostgreSQL database if you have the Hibernate plugin, a MongoDB instance if you have the Mongo plugin, and a Redis instance if you have that plugin.If you specify a service of the correct type (with the--services
attribute) then it'll be used, otherwise if you need one and have one provisioned it will be suggested to you, e.g.Would you like to bind the 'mysql-2f5fb76' service? ([y], n)
Would you like to create and bind a redis service? ([y], n)