Java Play 2 - Deployment

心不动则不痛 提交于 2019-12-03 21:58:51

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:

  1. on your local machine, in your project directory, run play dist
  2. send the dist/yourapp-1.0-SNAPSHOT.zip file (or whatever dist name you have configured) to the EC2 instance
  3. ssh to your instance
  4. unzip the dist file in the directory you want and cd there
  5. run chmod +x start
  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!