(Quick Reference)

6 Monitoring - Reference Documentation

Authors: Burt Beckwith

Version: 1.2.3

6 Monitoring

Crashes

If a deployment or update fails, the script will display the application logs but you can view crash information and logs at any time.

Use the cf-crashes script to check if there have been recent crashes:

$ grails cf-crashes

+-------------+--------------------------------------+--------------------+ | Name | Instance ID | Crashed Time | +-------------+--------------------------------------+--------------------+ | myappname-1 | 9f3e61c9-7c64-4e57-ab3e-8d7e892dd722 | 04/11/2011 02:43PM | | myappname-2 | 17b6470c-6444-49f4-8981-d3bd7d7796dc | 04/11/2011 02:43PM | | myappname-3 | d1b99f31-203c-48e3-aa17-17ca26178a49 | 04/11/2011 02:44PM | +----------+-------------+----------------+--------------+--------------+

Use the cf-crashlogs script to view log files for crashed instances:

$ grails cf-crashlogs

==== logs/stdout.log ====

2011-03-03 14:50:23,904 [main] ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NullPointerException at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:87) … Caused by: java.lang.NullPointerException at $Proxy13.save(Unknown Source) … Stopping Tomcat because the context stopped.

Logs

Use the cf-logs script to view log files:

$ grails cf-logs

==== logs/stderr.log ====

Mar 3, 2011 2:51:32 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-50478 … INFO: Server startup in 9169 ms

==== logs/stdout.log ====

By default all logs are displayed, but you can limit it to one or more:

$ grails cf-logs --stderr

==== logs/stderr.log ====

Mar 3, 2011 2:51:32 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-50478 … INFO: Server startup in 9169 ms

And you can also write a log to a file instead of the console:

$ grails cf-logs target/myapp.stderr.log --stderr

Wrote logs/stderr.log to target/myapp.stderr.log

Viewing files

Use the cf-list-files script to view directory listings:

$ grails cf-list-files /

logs/ - tomcat/ -

$ grails cf-list-files tomcat

bin/ - conf/ - lib/ - logs/ - temp/ - webapps/ - work/ -

$ grails cf-list-files tomcat/webapps

ROOT/ -

$ grails cf-list-files tomcat/webapps/ROOT

META-INF/ - WEB-INF/ - css/ - images/ - js/ - plugins/

Use the cf-get-file script to view a file:

$ grails cf-get-file tomcat/webapps/ROOT/css/main.css

html * { margin: 0; /*padding: 0; SELECT NOT DISPLAYED CORRECTLY IN FIREFOX */ }

...

And you can also write the contents to a file instead of the console:

$ grails cf-get-file tomcat/webapps/ROOT/css/main.css target/main.css

Wrote tomcat/webapps/ROOT/css/main.css to target/main.css

Caldecott tunnels

The plugin has support for Caldecott tunnels to connect directly to Cloud Foundry services directly. Use the cf-tunnel and cf-tunnel-disconnect scripts to connect and disconnect.

To create a tunnel, enter interactive mode:

$ grails

You can either connect to a specific service:

grails> cf-tunnel --service=mysql-38874c4
| Tunnel is running on localhost port 10000

or omit the name and choose from a list:

grails> cf-tunnel
| You have the following services defined:
| 1: mysql-38874c4
> 
Please select a service (or 0 to quit):[0,1]

The first time you use this feature you'll notice that the script deploys a small "caldecott" application (you'll see it in the cf-apps output) that is used to manage the connections:

| Caldecott server app not found, deploying ...

You can also specify a custom port, otherwise the default of 10000 will be used.

After connecting the script will display connect information for use with commandline and GUI tools:

Connect your client with username=uLQYDu4OmR9U password=pz6pQ4zxX7Jr name=d30bcdb2254a457e9c3662da8f5da089
Example mysql client usage:
   mysql -h 127.0.0.1 -P 10000 -u uLQYDu4OmR9U -ppz6pQ4zxX7Jr -D d30bcdb2254a457e9c3662da8f5da089

When you're finished, run the cf-tunnel-disconnect script to close the tunnel.