Updated 08.18.2012
I am using Play 2.0.2 and I want to deploy my app to Amazon Webservices. I think the easiest way to do this is via Elasticbeanstalk.
I used Play2war to package my app https://github.com/dlecan/play2-war-plugin/
I was able to package it with
play war
According to the usage guide of play2war, I renamed my file to ROOT.war because i used Linux 32bit Tomcat7.
I also used the servlet 3.0 as described in the tutorial on play2war. (tomcat 7 -> servlet 3.0).
The file size is 31mb.
Every time I use Elasticbeanstalk, I get the same log.
2012-08-18 00:25 GMT+0200
WARN
Environment health has been set to RED
2012-08-18 00:25 GMT+0200
INFO
Launched environment: elosource. However, there were issues during launch. See event log for details.
2012-08-18 00:25 GMT+0200
INFO
Your health check URL may be misconfigured. If your application does not respond to requests at http://elosource.elasticbeanstalk.com:80/, modify the health check URL to a valid path.
I tested it with Linux 32/64 bit , Tomcat7(servlet 3) and Tomcat6(servlet2.5). I always get the same result.
I also tried adding an extra html file for the health checker.
What would you recommend me to do?
What alternatives do I have to get my app running on ec2?
Is there a guide that explains how I manually deploy my app to ec2 with all the needed dependcies, like mongodb, play etc?
Also WAR files are relatively huge ~30mb, with my dsl 1k it is a real pain to upload such a lage file. Is there a way to only upload the changes with Elasticbeanstalk?
Ok, I know this is not the straight answer to your question as I am not using beanstalk, but as you asked for it in one of the comments:
Here is how I run my play2 app on a linux EC2 instance with a jvm installed:
- on your local machine, in your project directory, run
play dist
- send the
dist/yourapp-1.0-SNAPSHOT.zip
file (or whatever dist name you have configured) to the EC2 instance - ssh to your instance
- unzip the dist file in the directory you want and
cd
there - run
chmod +x start
- run
nohup ./start &
you now have your play2 application running natively on EC2, with websocket and all the cool stuff. I didn't have to configure anything special in play for that to work. I am using an RDS database configured as any other DB in play.
Clearly, it's a bit more hassle than beanstalk as you have to configure the server on your own and set up the autoscaling manually. But this is the best way that I have found to run play2 with all the features on AWS for now.
I hope this helps.
You should not package your application as a war, unless you are obligated to do or have a very good reason, as you will loose great features of the framework (even with servlet 3.0 you will miss websocket support).
An option is to deploy your app through dotCloud service. The service runs on top of Amazon EC2 and enables you to choose your stack and scale vertically easily. Of course you have to decide if it is worth the price, but you could test for free.
There as well other PaaS providers, that let you deploy play 2 applications:
INFO: The APR based Apache Tomcat Native...
is not the important part. Tomcat will start without it, and compiling it won't make your instance healthy. In fact, your catalina.out
logging looks totally normal.
My guess would be Beanstalk's error messages are accurate: You've got a misconfigured health check URL. For whatever reason, you application just isn't returning a root document on port 80, a problem that could arise in a few ways. Try adding a static html or simple jsp page to your app's root directory (top-level in the WAR), and have Beanstalk check for that. Beanstalk's default port configuration should work (if I recall correctly it passes traffic via apache to tomcat and back, but I haven't looked in a while), but it couldn't hurt to check $CATALINA_HOME/conf/server.xml
anyway just to see what's up.
If you are willing to upgrade to Play 2.3.x or newer, Boxfuse has native Play 2 support to address this.
You can now simply do boxfuse run my-play-app-1.0.zip -env=prod
and this will automatically:
- create a minimal AMI tailor-made for your Play 2 app
- create an elastic IP
- create a security group with the correct permissions
- launch an instance of your app
All future updates are performed as blue/green deployments with zero downtime.
This also works with Elastic Load Balancers and Auto-Scaling Groups and the Boxfuse free tier is designed to fit the AWS free tier.
You can read more about it here: https://boxfuse.com/blog/playframework-aws
Disclaimer: I'm the founder and CEO of Boxfuse
来源:https://stackoverflow.com/questions/11918820/java-play-2-deployment