-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Play 2.0 is a high-productivity Java and Scala web application framework that integrates the components and APIs you need for modern web application development.
Play is based on a lightweight, stateless, web-friendly architecture and features predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications thanks to its reactive model, based on Iteratee IO.
- Installing Play 2.0
- Creating a new application
- Anatomy of a Play 2.0 application
- Using the Play 2.0 console
- Setting-up your preferred IDE
- Sample applications
- The Build system
- Working with public assets
- Managing database evolutions
- Configuration file syntax and features
- Deploying your application
- Building Play 2.0 from source
- CI server at Cloudbees
- Repositories
- Issue tracker
- Pull requests
- Contributor guidelines
The documentation is freely editable on https://github.com/playframework/Play20/wiki. Feel free to fix mistakes directly in the pages.
However if you want to provide additional documentation, please create new pages and reference them from here. A member of the core team will take care of integrating it in the most appropriate section.
Deploy play 2.0 app on cloudfoundry:
Prerequisite:
Before you can deploy your app in cloudfoundry.com - you need to open an account with cloudfoundry.com. After registering it takes a day or two to get your account activated. You also have to have either the vmc command line tool or STS (eclipse plugin) installed on your system - visit the http://docs.cloudfoundry.com/getting-started.html link and follow the instructions there.
Once you have set-up the pre-requisites and got your user name and password from cloudfoundry.com - you are all set to deploy your app on cloudfoundry.com Paas.
I am going to use the vmc command line tool to deploy a newly created play 2.0 application on cloudfoundry.
Follow the steps below to deploy your app.
a). Launch command prompt.
b). Type in -> play new myPlayApp
ratul@ubuntu:~$ play new myPlayApp play! 2.0.1, http://www.playframework.org
The new application will be created in /home/ratul/myPlayApp
What is the application name?
myPlayApp
Which template do you want to use for this new application? 1 - Create a simple Scala application 2 - Create a simple Java application 3 - Create an empty project
1
OK, application myPlayApp is created.
Have fun!
c). Open the newly created myPlayApp/app/controllers/Application.scala file in a text editor.
Change definition of the index method like so:
def index = Action { val port = System.getenv("VCAP_APP_PORT") val host = System.getenv("VCAP_APP_HOST") println("App port : "+ port+" and host: "+ host) Ok(views.html.index("Your new application is ready."+ "App port : "+ port+" and host: "+ host)) }
Note: VCAP_APP_PORT & VCAP_APP_HOST are port name host names cloudfoundry assigns when it runs your app.
d). Save the Application.scala.
e). Open the myPlayApp/app/views/index.scala.html in a text editor and change the line that reads @play20.welcome(message) to @message and save it.
f). On the command, cd myPlayApp -> ratul@ubuntu:~$ cd myPlayApp/
g). launch the play prompt by tying 'play'.
ratul@ubuntu:~/myPlayApp$ play [info] Loading project definition from /home/ratul/myPlayApp/project [info] Set current project to myPlayApp (in build file:/home/ratul/myPlayApp/)
play! 2.0.1, http://www.playframework.org
Type "help play" or "license" for more information. Type "exit" or use Ctrl+D to leave this console.
h). Next we will bundle the application. So type 'dist' on the play prompt.
[myPlayApp] $ dist
[info] Updating {file:/home/ratul/myPlayApp/}myPlayApp...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /home/ratul/myPlayApp/target/scala-2.9.1/classes...
[info] Packaging /home/ratul/myPlayApp/target/scala-2.9.1/myPlayApp_2.9.1-1.0-SNAPSHOT.jar ...
[info] Done packaging.
Your application is ready in /home/ratul/myPlayApp/dist/myPlayApp-1.0-SNAPSHOT.zip
[success] Total time: 12 s, completed 12 May, 2012 2:56:34 PM
i). We want to push the application contents as folder structure and not as zip so that we want to be able to push deltas later on. Hence open the folder myPlayApp/dist in your explorer and extract the contents inside 'myPlayApp-1.0-SNAPSHOT.zip' in the same folder.
j). Delete the myPlayApp-1.0-SNAPSHOT.zip. Go inside the myPlayApp-1.0-SNAPSHOT folder and delete the README and start files as well - we do not need them.
k). Now we are ready to push our content to cloudfoundry. Let's login to cloudfoundry first.
l). On the command prompt come out from the play prompt by typing 'exit'.
m). cd dist/myPlayApp-1.0-SNAPSHOT/
n). Type 'vmc login' on the command prompt.
ratul@ubuntu:~/myPlayApp/dist/myPlayApp-1.0-SNAPSHOT$ vmc login Attempting login to [http://api.cloudfoundry.com]
Email: [email protected] Password: ****************** Successfully logged into [http://api.cloudfoundry.com]
o). On the prompt type : vmc target api.cloudfoundry.com
ratul@ubuntu:~/myPlayApp/dist/myPlayApp-1.0-SNAPSHOT$ vmc target api.cloudfoundry.com Successfully targeted to [http://api.cloudfoundry.com]
p). When prompted by vmc, answer with y or n as shown below.
ratul@ubuntu:~/myPlayApp/dist/myPlayApp-1.0-SNAPSHOT$ vmc push
Would you like to deploy from the current directory? [Yn]: y
Application Name: myPlayApp
Detected a Standalone Application, is this correct? [Yn]: y
1: java
2: node
3: node06
4: ruby18
5: ruby19
Select Runtime [java]: 1
Selected java
Start Command: java $JAVA_OPTS -Dhttp.port=$VCAP_APP_PORT -cp "dirname $0
/lib/*" play.core.server.NettyServer dirname $0
Application Deployed URL [None]: myPlayApp.${target-base}
Memory reservation (128M, 256M, 512M, 1G, 2G) [512M]: 256M
How many instances? [1]: 1
Create services to bind to 'myPlayApp'? [yN]: n
Would you like to save this configuration? [yN]: y
Manifest written to manifest.yml.
Creating Application: OK
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (80K): OK
Push Status: OK
Staging Application 'myPlayApp': OK
Starting Application 'myPlayApp': OK
ratul@ubuntu:~/myPlayApp/dist/myPlayApp-1.0-SNAPSHOT$
q). In your browser you can now open your application - type in myPlayApp.cloudfoundry.com - and we are done!
r). The browser will show something like :
Your new application is ready.App port : 61897 and host: 172.30.50.24
###Needs to be integrated Play 2.0 for Play 1.x developers