Community contributed extensions

Creating a new play project and deploying it to playapps.net

You can deploy a new play application in minutes to playapps. Let’s start.

Download play-1.1

Download the play-1.1 binary release at http://www.playframework.org and install it.

Install the ‘playapps’ module<:a>

Using the playapps module make the application deployment easier. Install this module to your local distribution by typing 'play install playapps':

~$ play install playapps
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.1, http://www.playframework.org
~ framework ID is dev
~
~ Will install playapps-1.1
~ This module is compatible with: 1.1
~ Do you want to install this version (y/n)? y
~ Installing module playapps-1.1...
~
~ Fetching http://www.playframework.org/modules/playapps-1.1.zip
~ [--------------------------100%-------------------------] 17.6 KiB/s   
~ Unzipping...
~
~ Module playapps-1.1 is installed!
~ You can now use it by add adding this line to application.conf file:
~
~ module.playapps=${play.path}/modules/playapps-1.1
~

Create the new project

Now you can create a new play application with the standard 'play new {projectname}' command. By specifying the '--with playapps' option, the playapps module will prepare your application.conf file for playapps hosting.

~$ play new my-test-project --with playapps
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.1, http://www.playframework.org
~ framework ID is dev
~
~ The new application will be created in ~/my-test-project
~ What is the application name? Test project
~
~ Adding playapps.net default configuration to application.conf
~

Once the project created you can take a look at the application.conf file.

# playapps.net configuration
# ~~~~~
%playapps.application.mode=prod
%playapps.application.log=INFO
%playapps.db=mysql:play:play@play
%playapps.jpa.ddl=update

As you see, it contains the default configuration for the playapps environment. You can learn more about play environment management on the corresponding playframework.org documentation page.

Deploying to your slot

Using the 'playapps:deploy' command is the easiest way to deploy your application to an existing slot. First the script will ask for your playapps.net account informations:

~$ play playapps:deploy my-test-project/
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.1, http://www.playframework.org
~ framework ID is dev
~
~ Creating archive from ~/my-test-project to ~/tmp/my-test-project.zip ...
~ Done (0MB)
~ 
~ What is your email? [email protected]
~ What is your password?

Then select the slot you want to deploy your new application on:

~ Connected, choose your application:
~ 	1. playapps.net
~ 	2. mytest
~ ? 2

The script will check your application state. In order to deploy an new version of your application, playapps will set your slot in maintenance mode. It means that it will stop the play application and switch the HTTP server to private mode. This way during the deployement process your users will see a maintenance page if they try to access your application.

So, if you are sure to want to shutdown temporarily your application, answer ‘y’:

~ Checking application state...
~
~ We need to stop your application and set the HTTP server in maintenance 
~ before before deploying
~ Are you sure [y/N]? y

Now the script will check for your existing backups. At this point you can ask playapps.net to create a snapshot backup before the deployement process. If something goes wrong with your new version, you can rollback immediately to the latest working version. It includes the application itself but also all the storage and MySQL data as well.

So it is generally a good idea to answer ‘y’:

~ Setting the slot in maintenance mode...
~ Ok
~
~ Verifying backups...
~ Your last backup has been created on Thu Jun  3 12:00:01 2010
~ Do you want to create a backup now [Y/n]? y

Finally your application will be uploaded to your slot in order to be installed.

~ Uploading archive...
~ [--------------------------100%-------------------------] 
~
~ Installing....
~ [--------------------------100%-------------------------] 

Once your application is installed, the script will ask to start your application. If you want to start it immediately, answer ‘y’:

~ Do you want to start the application now [Y/n]? y
~
~ Starting the application...
~ Started
~
~ You can use your private access to check the application at http://ukxsbnjyzmapwxx
~ Then open the HTTP server using the web console at 
~ http://playapps.net/[email protected]/mytest

Once your application is installed and started, the HTTP server is still in private access mode. That means that your users still can’t access the application. It is generally a good idea to try the application yourseld using your private access to check that all is ok.

When you are sure that your new application is ready, you can go to the playapps.net manager and open the HTTP server again.

Done! Your application is now live.

Prepare an existing application for playapps deployement

To update an existing play project, first install the 'playapps' module and update your application.conf file with:

playapps.module=${play.path}/modules/playapps-1.1

Then you have to define the configuration options for the playapps environment. Add these lines to application.conf:

%playapps.application.mode=prod
%playapps.application.log=INFO
%playapps.db=mysql:play:play@play
%playapps.http.port=9000
%playapps.jpa.ddl=update

Running application in prod mode and on HTTP port 9000 is required for playapps. Also, if your application is using a database, you need to configure the db property to 'mysql:play:play@play'. And you can set the log level to any value from DEBUG to ERROR.