Saturday, August 10, 2013

Switching from cloudfoundry V1 to V2

Beta version of Cloudfoundry is down since long time ago. Now Pivotal gave users V2, brand new commercial version of former service. It's yet 67 days for free. I decided to migrate my V1 app there. Let's see how deployment process differs from the old one.
Previously there was grails plugin that made it as simple as invoking several groovy commands. Now it's a bit different. Quick manual is available at

I'm not Ruby hacker but was able to install Ruby on my machine, yet starting with first command I encountered an issue. DevKit was missing on my machine, so i donwloaded it from here (DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe), extracted in my groovy_home/DevKit and installed with commands:
cd C:\Ruby193\DevKit
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install
Then lets return to cloudfoundry install cf.

gem install cf

cf target

When we have done it already we can build war file (grails prod war) and upload it.

cf push --path consulner.war

When we do this for the first time we will be asked to choose environment (dev, staging, prod) I've chosen production. Then I answered questions as follows:

Name> consulner

Instances> 1

1: 128M
2: 256M
3: 512M
4: 1G
Memory Limit> 3

Creating consulner... OK

1: consulner
2: none
Subdomain> consulner

2: none

Binding to consulner... OK

Create services for application?> n

Save configuration?> y

Saving to manifest.yml... OK
Uploading consulner... OK
Preparing to start consulner... OK
-----> Downloaded app package (28M)
Downloading JDK...
Copying openjdk-1.7.0_25.tar.gz from the buildpack cache ...
Unpacking JDK to .jdk
Downloading Tomcat: apache-tomcat-7.0.41.tar.gz
Copying apache-tomcat-7.0.41.tar.gz from the buildpack cache ...
Unpacking Tomcat to .tomcat
Copying mysql-connector-java-5.1.12.jar from the buildpack cache ...
Copying postgresql-9.0-801.jdbc4.jar from the buildpack cache ...
Downloading auto-reconfiguration-0.7.1.jar from ...
-----> Uploading droplet (65M)
Checking status of app 'consulner'.....
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 starting)
  1 of 1 instances running (1 running)
Push successful! App 'consulner' available at

That's it! Now we have app running on prod. Unfortunately this was not that simple, I struggled to find out why the app could not start t first time and there was nothing inspiring in logs or crushlogs. Finally I tried increasing default memory from 256M to 512M and it worked :)