Friday, May 30, 2014

Deploy your Tomcat Grails website on OpenShift

Deploy your Grails web site on OpenShift

I use OpenShift cloud to deploy my web site made with Grails. This article will give you a summary of what you have to do if you want to deploy a web site on OpenShift cloud. It will also give some advice and feedback.


 Which way to deploy your Grails application on OpenShift ?

The best way I found to deploy my Grails application is to build a war and then deploy it on Openshift.

By default, Grails has the war command available : grails war

See also the Grails web site for more details about it :

Note :

  • You can use Tomcat plugin to makes Tomcat the default servlet container for Grails at development time.
  •  You can delete unwanted files in your war by adding some configuration in Config.groovy :
    1:  grails.war.resources = {  
    2:     stagingDir -> delete(dir: "$stagingDir/selenium")   
    3:  }   

Install and configure Openshift client

First of all you have to create an account on Openshift then you will be able to install and configure openshift tools. You only have to install rubygems and git package. For example, on Gentoo, type the following commands :

 emerge dev-ruby/rubygems  
 emerge git   

If you don't have Gentoo, you can see on the openshift website :
Then, you only have to execute following command :

 gem install rhc  
 su - user  

Here is an example :

#rhc setup
OpenShift Client Tools (RHC) Setup Wizard

This wizard will help you upload your SSH keys, set your application namespace, and check that other programs like Git are properly installed.

Using XXXX to login to
Password: ******

OpenShift can create and store a token on disk which allows to you to access the server without using your password. The key is stored in your home directory and should be kept secret.  You can delete the key at any time by running 'rhc
Generate a token now? (yes|no) yes
Generating an authorization token for this client ... lasts about 1 month

Saving configuration to /home/USER/.openshift/express.conf ... done
Checking for git ... found git version
Checking common problems .. done
Checking for a domain ... MYDOMAIN
Checking for applications ... found 1

  You are using 1 of 3 total gears
  The following gear sizes are available to you: small

Your client tools are now configured.

Deploy your application on the cloud

Once, you can access with ssh and you have a war application, you only have to copy it on your account.OpenShift uses Git to push your application on the cloud :

In our case, you had to make some change if you want it works. See my tips :

Access in your application


How to connect with ssh ?

  • Go and Log in openshift website.
  • Clic on Application tab
  • Clic on your application

  • At the right of the screen, clic on the link : "Want to log in your application 
  • Copy the line in your console.

For example :

#ssh 529e2274e0b???

Usefull commands

ctl_app stop
ctl_app start

If you want more details, here is usefull links :


Visit your website

 The access link for your web site is in the openshift website ( Clic on your Application in the Application detail ).

Response time very long

I had a problem with very long time to first access to my web site.I found solution on StackOverFlow :

 openshift : my local gears often timeout and go down which cause response time very long

If you do not access your application for 24 hours, it will get idled (if this is a free acount), and depending on how large your application is, it could take awhile to spin back up when you do access it again.

To conclude

Deploy a web site on OpenShift cloud was not really diffcult.Just keep in mind that whit free account you have to access every 24 hours to your web site. Some people has also difficulties with proxy configuration ...
If you wan to see an example of source code, you can look at my GitHub project example : can also visit the project on the web at