RUN@cloud » Playframework

Playframework

Last modified by Jose Salguero on 2012/04/24 20:34

Getting Started

Getting the framework

Playframework can be downloaded from here.

Setting up the framework

Unzip the play zip file you just downloaded to any path that suits you. You'll need to add that folder to the the system path.

Optional: install plugin modules globally

In play, modules can either be installed globally on a system, or locally into the play web application directory. The advantage to installing globally is that it will not have to re-download the same module for multiple projects. If you use (or want to try) CloudBees RUN@Cloud there is a module available to help out with deploying your application.

play install cloudbees

If you want to use scala, this is a good time to install the module as the scala runtime libraries are on the bigger side.

play install scala-0.9.1

Creating a new web application

~/CloudBees $ play new cloudbees-test
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.3, http://www.playframework.org
~
~ The new application will be created in /Users/ivan/CloudBees/cloudbees-test
~ What is the application name? [cloudbees-test]
~
~ OK, the application is created.
~ Start it with : play run cloudbees-test
~ Have fun!

* If you want a scala app use "play new cloudbees-test --with scala-0.9.1", this will generate scala sample code rather than java.

You have created a new application! you can run it by executing "play run cloudbees-test". Once it has started if you browse to http://localhost:9000 you'll see a sample page. Stop the application for now.

Adding modules

Modules for an application are defined in conf/dependencies.yml. Edit this file to be like the following...

# Application dependencies

require:
   - play
   - play -> cloudbees 0.2.2

Once the file has been saved, run "play deps cloudbees-test --sync". This will download the module into modules/ if you haven't installed it globally, or if you have it will symlink it to the modules/ directory.

Edit your Application.conf to connect to your CloudBees database.  Note that it's easiest to use the standard MySQL driver.  You can get the DB_HOST value from your Database's configuration page.
# Database configuration
# 01:07, 8 January 2010 (UTC)
#db=mysql
#db=java:/comp/env/jdbc/yourProject

db.url=jdbc:mysql://DB_HOST/yourDataBaseName
db.driver=com.mysql.jdbc.Driver
db.user=login
db.pass=password

jpa.dialect=org.hibernate.dialect.MySQLDialect

Uploading to CloudBees RUN@Cloud

Once you have the CloudBees module installed in the project you can upload it to RUN@Cloud

play bees:app:deploy cloudbees-test --key <apikey> --secret <api secret> \
     --app-name <name of app in cloudbees>
     --app-domain <account name in cloudbees>

or, even better, adding these lines to application.conf:
bees.api.key=<your api key>
bees.api.secret=<your api secret>
bees.api.domain=<your account name>
bees.api.name=<your application name>

and then just issuing this command:
play bees:app:deploy

When that is done you should be able to access your application at the url returned by the command.

Created by Ivan Meredith on 2011/06/17 23:16
 


All Rights Reserved - CloudBees, Inc. - 2012
XWiki Enterprise