Monday, May 31, 2010

Announcing TurboGears EC2 Images

Amazon has long offered a service whereby the community can purchase time on their clusters. Today, TurboGears is able to take advantage of this in a new way. It is now easier than ever before to get a TurboGears instance up, running, and viewable by you, allowing you to find out how that TurboGears based application really looks and functions.

The whole process is actually fairly simple. You will need to know the AMI ID of the version of TurboGears you wish to test. Here are the AMI IDs we have available now. This post will be updated when new versions of the AMIs are made available.

  • TurboGears 2.0.3, 32 Bit - AMI ID: ami-c5648dac
  • TurboGears 2.0.3, 64 Bit - AMI ID:  ami-a17e97c8
  • TurboGears 2.1b2, 32 Bit - AMI ID:  ami-67678e0e
  • TurboGears 2.1b2, 64 Bit - AMI ID:  ami-7b719812

Installing your application and getting it live is very simple. If you don't know how to work with Amazon's EC2 service, please read their documentation for it. Here's the process:
  1. Launch an instance of the AMI you have selected.
  2. Log in to the instance:
    sudo su - turbogears
  3. Install the application following whatever directions are provided by the application, but do not run "paster setup-app" yet.
  4. Instead of making "production.ini" or "deployment.ini", you will make "/home/turbogears/app.ini". This is absolutely identical to the other files, it's just the name that is special. Yes, you can modify configuration to use one of the other names, but you do not have to.

    When you do make this file, don't forget to set "debug=false" in it. This is meant to be a production environment, and will break if "debug=true" is set.
  5. Run the following two commands:
    cd $HOME
    paster setup-app tgapp.ini
  6. If your configuration uses a SQLite database, don't forget to fix the permissions. Either make www-data the owner, or set the permissions to 0777.
  7. A couple of files need to be made, but will be made automatically for you. When you installed the application in step 3, a Python egg was installed. You will need the name of that egg (but can find it fairly easily). A command has been written to make this whole part of the process painless. Do this:

    tglinker eggname eggversion

    If you are unsure of the eggname, simply type "tglinker", followed by a space, and then press the tab key twice. You will be given a list of all installed eggs, and can start typing the name in from that list. Once you get enough to be unique, press tab again, and the name will be completed.

    Once you have that, the eggversion will be even easier: Pressing tab twice will likely fill in the full version number. If not, simply type it in again usaing the tab completion as above.

    Press enter, and the required files will be generated.
  8. Finally, logout of the turbogears user account (either by using the "exit" command, or the "logout" command), and restart apache using this command:

    sudo /etc/init.d/apache2 restart
You're done, and by visiting "" in your browser, you will now see your web site function.

A word of caution: If you are a new user of the EC2 service, you might well terminate any instance that you create. All data on the local drive will be destroyed.  Their documentation covers how to preserve data. I recommend you read it.

No comments: