Google App Engine Deployment Tips

I uses Google App Engine for few of my projects. I choose it, because it is Free for small application like blog and faster, easy to deploy. This blog is also deployed in the App Engine.

Command Line Alias

I usually deployed to Google App Engine from command line. I have aliases for deployment and rollback.

$ alias gaed='/Users/maasan/development/tools/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.3/appengine-java-sdk-1.7.3/bin/appcfg.sh update war'

$ alias gaer='/Users/maasan/development/tools/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.3/appengine-java-sdk-1.7.3/bin/appcfg.sh rollback war'

When I want to deploy, I just change to application directory and run

$ gaed

If you want update the version of application, then

$ gaed -v 2

The version can be anything from single integer or current date or anything you like.

Different versions access

Even though you deployed the new version of your application to App Engine, it will not come to live until you go to Admin console and set as Default. Once you set new version as Default, then it comes to live.

But will there any way to access the old versions when new version is live?

Yes, I recently found that we can access any version of your application by

http://<version>-dot-<application identifier>.appspot.com

Let's assume, you want to access the version 1 of your sample.appspot.com, then

http://1-dot-sample.appspot.com

But keep in mind that all your application will use same database. If any changes in the database schema might break the older versions.

You can also use it vice-versa. Just deploy the new version, access the new version by above version URL and test it. Once you confidence that you can make it live, then go and set the new version as Default.

Happy deployment and Have a nice day.

View comments

JSON is not Javascript Object

Many people treat JSON as javascript object. But really it is not. JSON is just string representation inspired from Java Script Object structure. JSON is designed to ease and simplify the data transfer between server and browser. Because of the simplicity, it works among other applications not just between browser and server.

I try to copy some javascript object and send over to JSON based bookmark web server. But it does not work, why? Lets have javascript object that I tried to sent.

{
    name : "why this kolaveri di",
    url  : "http://www.youtube.com/watch?v=YR12Z8f1Dh8",
    singer: "Dhanush",
    movie: "3",
    music : "Anirudh Ravichandran",
    views : 10000000,
    // Adding this for testing purpose
    play : function() { },
}

When I sent this, I got the error Unexpected token n from the server (By the way, I uses NodeJS with Express framework). It means, it is not valid JSON. I wonder why it is not working. Then I read JSON spec by Douglas Crockford and understood the followings

1. All keys should be double quotes.
2. JSON does not support comments.
3. JSON value should not be function or undefined. A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.
4. Last value of JSON should not have comma(,) separator.

Then it changed into

{
    "name" : "why this kolaveri di",
    "url"  : "http://www.youtube.com/watch?v=YR12Z8f1Dh8",
    "singer": "Dhanush",
    "movie": "3",
    "views" : 10000000,
    "music" : "Anirudh Ravichandran"
}

Take away

I think, it is very important to learn the JSON notation since we have lot of our configuration files(package.json, bower.json) in web development in JSON format. So understanding about JSON is must for every web developers.

Happy coding and Have a nice day.

View comments