Monday, March 12, 2012

Deploying Existing Play! Application to Jelastic


If you had an existing play application and you want to put it on Jelastic, the easiest way is to use Jelastic Plugin on Play!.

The Requirement:
  • You need to have an existing Jelastic Envorinment (if you’re Play! application used a database, your environment must have database enable and also configured (means you have your database create with appropriate user assigned to it)
  • Your application must use Play! version must be 1.2.x.


Steps:
  1. On your application.conf add this jelastic configuration

jelastic.api.login=login@domain.com
jelastic.api.password=yourpassword
jelastic.api.context=defaultLocationOnEnvironment
jelastic.api.environment=’environmentName
jelastic.api.apihoster=api.jelastic.com
Example:
jelastic.api.login=barramedalb@gmail.com
jalestic.api.password=6680539
jelastic.api.context=ROOT
jelastic.api.environment=aims-jam
jelastic.api.apihoster=app.jelastic.servint.net

jelastic.api.login and password are your credentials to log onto jelastic app controller. Jelastic.api.context specifies where the application will be deployed, in the example ROOT means it is deployed and accessible by the domain name which is aims-jam.jelastic.servint.net. If I put app on jelastic.api.context, my application will be deploy on app context and can be access on aims-jam.jelastic.servint.net/app. jelastic.api.environment which is the name of your environment defined on your apihoster.

Moreover, jelastic.api.apihoster can only have two value which are: app.jelastic.com (host on Europe), and app.jelastic.servint.net (host in North America).

  1. Configure your jdbc on application.conf.

db.url=jdbc:mysql://environmentName.yourapihoster/dbName
db.driver=com.mysql.jdbc.Driver
db.user=dbUserName
db.pass=dbUserPassword

Example:
db.url=jdbc:mysql://aims-jam.app.jelastic.servint.net/aims-jam
db.driver=com.mysql.jdbc.Driver
db.user=getch123
db.pass=123456789

You can define this on the phpMyAdmin of jelastic.
  1. Increase your db.pool.timeout to 10000ms of application.conf

db.pool.timeout=10000

  1. Deploy your application to jelastic cloud by (must be on the application directory):

play jelastic:deploy


This will take a while depending on your internet upload speed, this will compile your application and create a war file and then will upload it to jelastic. If it is finish, you can now access your application. In my example, I can access my application on aims-jam.jelastic.servint.net.

It seems that jelastic plugin can only work the default environment specified on application.conf, so I created a new environment that I named localhost for my localhost testing environment.

If I am testing my application locally, I will execute: play run --%localhost

Hope this can help you. :)

Resources:




5 comments:

  1. Hi i have play2.0. i downloaded jelastic-0.2 . now when i do >play install ./jelastic-0.2
    i get a message "This is not a play applicaition" What am i doing wrong

    ReplyDelete
    Replies
    1. try installing jelastic-0.2 by executing this command:


      play install jelastic

      Delete
    2. This doesn't work. In jelastic module description read:
      This module is for the Play 1.x series only.

      So if you want to use newer version of Play 2.x, you're out luck with Jelastic. Have to use some other cloud solution.

      Delete
  2. Nice Tutorial!!! it is helpful...Thanks!

    ReplyDelete