Grails App On Google App Engine

I wanted to collect things I know about the health care process into an application and decided a Grails app running on Google App Engine would be a fun way to go.  This is how I got things launched, and you might be able to use this for your app.

The reason I chose the Google platform was cost.   The idea of an Amazon EC2 environment and platform as a service really appeals to me, and in fact this site is served up from a PHP/Servlet container Linux server I rent on my ISP provider.  But a lot of the providers cost quite a bit more than I want to spend now to play with concepts.  Google is a bit quirky but I think in the future the cloud platforms will be much more standard and accommodating to widespread tech and code — seems to be where Amazon, Salesforce, VMWare etc. are all heading.  Some of us will write the code that binds it — just like no one worries about connection pooling anymore, a lot of the stuff will become transparent and we can just code.  Not today though.

And a lot of times, I don’t want to be a programmer per se, instead, I just want to do make my idea real.    I am hoping the Google platform can help me do this quickly.

Before you start, you’ll have to get a Google app engine account using your cell phone because they will SMS text a confirmation number to you.  I wasn’t confortable doing this, so at Walmart I picked up a TracFone pay as you go for $10, and it had 20 total minutes that came free with it.   I priced out other could platforms and you have to really pay big (Although now Amazon has a year of free services for new people on a small scale).  $10 for my piece of mind seems reasonable.  Also — a cool phone for $10 is quite amazing, I was shocked.   I’ll probably write an article up on the Ivy Street Design site about it.  But Onto Business.

How to get a Grails App Up onto Google Apps, in Meta terms.   I am assuming the person reading this is already a Grails developer familiar with fundamental actions.

Setup

  1. Get a Google App Engine account.
  2. Choose a name for your app and set up an application space in it.  It will end up being something like “<yourapp>.appspot.com” for the url, since appspot serves them up at Google.
  3. OK — you should have your IDE and machine set up for Grails.   I’m not going through it so make sure GRAILS_HOME and GROOVY_HOME environment is set up in your environment (with the /bin’s in the PATH, just like the JAVA setup you should have done).
  4. Download the Google Apps SDK for Java on their site.  Unzip it to your library spot then, set up the APPENGINE_HOME env variable and add the /bin to the PATH variable.
  5. Test your setup quick.  Open a terminal up and type in and test each of:
    • groovy -version
    • groovy -version
    • appcfg -h
  6. Create a grails application in your IDE.
  7. OK — important — you will have to remove the hibernate plugin from your project if it is in there (Google App Engine cannot run full blown hibernate).  Also, I removed the tomcat plugin. Since I am using Netbeans as my IDE for this it might have thrown that in there.
  8. Install the app-engine plugin into your project.
  9. Configure appengine-web.xml in your app directory.  Set <application> to the name of your target app in Google App Engine, and the <version> number.

Run the App

Now that you are set up you can run the app in the local app engine that you downloaded with the Google Java SDK.  I found that the Netbeans plugin for Google App Engine not too helpful at all — it wouldn’t let me add a Grails app to the server.  You can find it on the Kenai.com site, or maybe have better luck with Eclipse.  For now though running from the command line is good.  Should know how to do that anyway.

Go to your Grails application directory.  and execute:

grails app-engine run

It will take a bit for it to build and run, but the command line will tell you its ready and you can go to http://localhost:8080/ and see your app.  Also note that the org.grails.appengine.AppEngineReloadController will show up under the controller list.

I just ctrl-c out of the service to stop it.

Upload the App

It’s simple to do this from the command line in your project’s directory.

Optional, set the version:

grails set-version 1

Now package up the app:

grails app-engine package

Then, upload:

appcfg update ./target/war

You’ll be prompted for your ID/password on the command line.  It won’t take long — and you will see your application served upp at <yourappname>.appspot.com.  Make sure to check out the administrative console on Google as well for your app.

My next step will be to delve into BigTable and the possible ORM functionality I can do, as well as work on my app.  I’m working on some writings about the NoSQL technology, should be fun.

Comments are closed.