(Quick Reference)

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

or if you're running the interactive script:

cf-bind-service mongodb-eaa5601

Creating new service binding to 'mongodb-eaa5601' for 'myappname'.

Application 'myappname' updated Service 'mongodb-eaa5601' added

Application 'myappname' stopped.

Trying to start Application: 'myappname'. .

Application 'myappname' started.

If you run cf-apps you'll see that the service is registered:

+-------------+----+---------+----------------------------+--------------------------------+
| Application | #  | Health  | URLs                       | Services                       |
+-------------+----+---------+----------------------------+--------------------------------+
| myappname   | 1  | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76, mongodb-eaa5601 |
+-------------+----+---------+----------------------------+--------------------------------+

Use the cf-unbind-service script to remove an existing service instance from your application:

$ grails cf-unbind-service mongodb-eaa5601

Removing service binding 'mongodb-eaa5601' from 'myappname'.

Application 'myappname' updated Service 'serviceName' removed

Application 'myappname' stopped.

Trying to start Application: 'myappname'. .

Application 'myappname' started.

If you run cf-apps you'll see that the service is no longer registered:

+-------------+----+---------+----------------------------+---------------+
| 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.com

Succesfully mapped url

If you run cf-apps you'll see that the extra URL is mapped:

+-------------+----+---------+-------------------------------------------------------------+---------------+
| Application | #  | Health  | URLs                                                        | Service       |
+-------------+----+---------+-------------------------------------------------------------+---------------+
| myappname   | 1  | RUNNING | myappname.cloudfoundry.com, myotherappname.cloudfoundry.com | mysql-2f5fb76 |
+-------------+----+---------+-------------------------------------------------------------+---------------+

Use the cf-unmap script to remove a URL from your application:

$ grails cf-unmap myotherappname.cloudfoundry.com

Succesfully unmapped url

If you run cf-apps you'll see that the URL is no longer mapped:

+-------------+----+---------+----------------------------+---------------+
| 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 3

Scaled 'myappname' up to 3 instance(s).

It will take a short amount of time to start the new instances, so if you run cf-apps you'll see that the extra instances are allocated but not all are running yet:

+-------------+----+---------+----------------------------+---------------+
| Application | #  | Health  | URLs                       | Service       |
+-------------+----+---------+----------------------------+---------------+
| myappname   | 3  | 33%     | myappname.cloudfoundry.com | mysql-2f5fb76 |
+-------------+----+---------+----------------------------+---------------+

Wait a while longer and all should be running:

+-------------+----+---------+----------------------------+---------------+
| Application | #  | Health  | URLs                       | Service       |
+-------------+----+---------+----------------------------+---------------+
| myappname   | 3  | RUNNING | myappname.cloudfoundry.com | mysql-2f5fb76 |
+-------------+----+---------+----------------------------+---------------+

If you have a test page that displays the environment variables VCAP_APP_HOST and VCAP_APP_PORT you'll see that you're automatically load-balanced randomly between the instances when you refresh your browser:

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

Use the cf-show-instances script to display information about the instances:

$ 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 | +-------+---------+--------------------+

Use the cf-stats script to display runtime information about the instances:

$ 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 | +----------+-------------+----------------+--------------+--------------+

You can also scale the number down:

$ grails cf-update-instances 1

Scaled '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 1G

Updated memory reservation to '1.0G'.

Application 'myappname' stopped.

Trying to start Application: 'myappname'. .

Application 'myappname' started.

Note that the memory must be one of 64M, 128M, 256M, 512M, 1G, or 2G.

Start, stop, restart

Use the cf-stop script to stop your application:

$ grails cf-stop

Application 'myappname' stopped.

Use the cf-start script to start your application:

$ grails cf-start

Trying to start Application: 'myappname'. .

Application 'myappname' started.

Use the cf-restart script to stop and then start your application:

$ grails cf-restart

Application '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-update

Uploading 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.war

Application '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-app

Application 'myappname' deleted.

Use the cf-delete-all-apps script to delete all applications:

$ grails cf-delete-all-apps

Application 'myappname1' deleted.

Application 'myappname2' deleted.

Application 'myappname3' deleted.