5 Updating applications and services - Reference Documentation
Authors: Burt Beckwith
Version: 1.2.3
5 Updating applications and services
Updating applications
Once an application has been created, there are several options for making changes to it:- binding and unbinding services
- mapping and unmapping URLs
- increasing or decreasing the number of running instances
- increasing or decreasing the amount of memory allocated
Services
Use the cf-bind-service script to associate an existing service instance with your application:grails cf-bind-service mongodb-eaa5601
cf-bind-service mongodb-eaa5601
Creating new service binding to 'mongodb-eaa5601' for 'myappname'.Application 'myappname' updated Service 'mongodb-eaa5601' addedApplication 'myappname' stopped.Trying to start Application: 'myappname'. .Application 'myappname' started.
+-------------+----+---------+----------------------------+--------------------------------+ | Application | # | Health | URLs | Services | +-------------+----+---------+----------------------------+--------------------------------+ | myappname | 1 | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76, mongodb-eaa5601 | +-------------+----+---------+----------------------------+--------------------------------+
$ grails cf-unbind-service mongodb-eaa5601Removing service binding 'mongodb-eaa5601' from 'myappname'.Application 'myappname' updated Service 'serviceName' removedApplication 'myappname' stopped.Trying to start Application: 'myappname'. .Application 'myappname' started.
+-------------+----+---------+----------------------------+---------------+ | Application | # | Health | URLs | Service | +-------------+----+---------+----------------------------+---------------+ | myappname | 1 | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76 | +-------------+----+---------+----------------------------+---------------+
URLs
Use the cf-map script to associate an additional URL with your application:$ grails cf-map myotherappname.cloudfoundry.comSuccesfully mapped url
+-------------+----+---------+-------------------------------------------------------------+---------------+ | Application | # | Health | URLs | Service | +-------------+----+---------+-------------------------------------------------------------+---------------+ | myappname | 1 | RUNNING | myappname.cloudfoundry.com, myotherappname.cloudfoundry.com | mysql-2f5fb76 | +-------------+----+---------+-------------------------------------------------------------+---------------+
$ grails cf-unmap myotherappname.cloudfoundry.comSuccesfully unmapped url
+-------------+----+---------+----------------------------+---------------+ | Application | # | Health | URLs | Service | +-------------+----+---------+----------------------------+---------------+ | myappname | 1 | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76 | +-------------+----+---------+----------------------------+---------------+
Instances
Use the cf-update-instances script to increase or decrease the number of running instances of your application:$ grails cf-update-instances 3Scaled 'myappname' up to 3 instance(s).
+-------------+----+---------+----------------------------+---------------+ | Application | # | Health | URLs | Service | +-------------+----+---------+----------------------------+---------------+ | myappname | 3 | 33% | myappname.cloudfoundry.com | mysql-2f5fb76 | +-------------+----+---------+----------------------------+---------------+
+-------------+----+---------+----------------------------+---------------+ | Application | # | Health | URLs | Service | +-------------+----+---------+----------------------------+---------------+ | myappname | 3 | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76 | +-------------+----+---------+----------------------------+---------------+
VCAP_APP_HOST 10.114.110.207 VCAP_APP_PORT 48684
VCAP_APP_HOST 10.114.110.208 VCAP_APP_PORT 47793
VCAP_APP_HOST 10.114.110.209 VCAP_APP_PORT 58232
$ grails cf-show-instances+-------+---------+--------------------+ | Index | State | Start Time | +-------+---------+--------------------+ | 0 | RUNNING | 04/12/2011 11:33AM | +-------+---------+--------------------+ | 1 | RUNNING | 04/12/2011 11:33AM | +-------+---------+--------------------+ | 2 | RUNNING | 04/12/2011 11:33AM | +-------+---------+--------------------+
$ grails cf-stats+----------+-------------+----------------+--------------+--------------+ | Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime | +----------+-------------+----------------+--------------+--------------+ | 0 | 9.5% (4) | 372.7M (512M) | 52.6M (2G) | 0d:0h:1m:12s | | 1 | 3.3% (4) | 375.7M (512M) | 52.6M (2G) | 0d:0h:1m:53s | | 2 | 3.7% (4) | 383.2M (512M) | 52.6M (2G) | 0d:0h:1m:55s | +----------+-------------+----------------+--------------+--------------+
$ grails cf-update-instances 1Scaled 'myappname' down to 1 instance(s).
Memory
Use the cf-update-memory script to increase or decrease the allocated memory for your application:$ grails cf-update-memory 1GUpdated memory reservation to '1.0G'.Application 'myappname' stopped.Trying to start Application: 'myappname'. .Application 'myappname' started.
Start, stop, restart
Use the cf-stop script to stop your application:$ grails cf-stopApplication 'myappname' stopped.
$ grails cf-startTrying to start Application: 'myappname'. .Application 'myappname' started.
$ grails cf-restartApplication 'myappname' stopped.Trying to start Application: 'myappname'. .Application 'myappname' started.
Updating
Use the cf-update script to redeploy an application after making code changes:$ grails prod cf-updateUploading Application. Building war file [gspc] Compiling 13 GSP files for package … … Building WAR file … [copy] Copying 635 files to … … [propertyfile] Updating property file: … … [jar] Building jar: .../target/cf-temp-1299178697861.war … Done creating WAR ...target/cf-temp-1299178697861.warApplication 'myappname' stopped.Trying to start Application: 'myappname'. .Application 'myappname' started.
Most scripts are not environment-specific but cf-update builds a war file, so be sure to specify the environment.Like the cf-push script you can either let the script create a war file for you, or specify an existing one.
Deleting applications
Use the cf-delete-app script to delete an application:$ grails cf-delete-appApplication 'myappname' deleted.
$ grails cf-delete-all-appsApplication 'myappname1' deleted.Application 'myappname2' deleted.Application 'myappname3' deleted.