Play 2.5.6 application on Tomcat or any alternative? - scala

I have created an application on Play framework 2.5.6. I am trying to find out what is the best way to deploy the application on production. I have tomcat installed on my Ubuntu machine. How to create war file and How to deploy on tomcat? I am using Scala Eclipse IDE for development.

Have a look at this other thread which is very similar to what you're asking here (albeit directed at GAE).
In a nutshell, the disadvantages of deploying your app to Tomcat are:-
you have extra work to do to package your application as a WAR
extra work to deploy it
your application may not be fully asynchronous running in Tomcat
As that outdated documentation suggests - the simplest way of deploying your app in production is just using the version of Netty which is packaged as part of a Play application. See the relevant version of the docs to create a distribution. You only need a relevant version of a JVM on your prod server in this case.
The flow is generally:-
Run $ dist to build the binary (this is a zip by default, but you can also build a tar if you prefer using $ universal:packageZipTarball instead of dist).
Move it into your Linux production environment
Unpack it
Set permissions if you build a zip $ chmod +x /path/to/bin/<project-name> (not required if you created the tar)
Run the app start script (created by the dist task) eg. $ target/universal/stage/bin/<project-name>

Related

How enable production mode in GWT 2.7 application

I would like to deploy my GWT 2.7 application on my server through gwt-maven-plugin and jenkins. But, after compile process, when I launch my application, I've this error message :
Couldn't load APPLICATION_NAME from Super Dev Mode
server at http://MY_IP:9876.
Please make sure this server is ready.
Indeed, the super dev mode is enabled by default since 2.7. So, how disable it to use production mode ?
Ok thank you very much for your comment. Indeed, my problem concerned the *.nocache.js and *.devmode.js files. I started my project (my first one in GWT) in 2.6 version and these files were created (by dev and super-dev-mode) and versionned by my fault. So, when my jenkins deployed my project, it used these files so even if I did mvn clean before deploy it had no effect.
So, I removed these files from my project and I did a mvn clean install before deploy to fix my issue.

AWS EB deployment - where is my app?

I packaged my Scala/LiftWeb app with the sbt one-jar plugin into a single executable jar file and packed it up with Docker, exposing the embedded Jetty's port in the Dockerfile.
It runs fine locally on Docker and appearently deploys clean on AWS EB using the CLI deployment tools. On the received EB URL however, all I see is the congrats page saying "Your Docker Container is now running in Elastic Beanstalk on your own dedicated environment in the AWS Cloud.".
So, where is my app? Do I miss any steps making my app publicly available on my EB instance?
For future reference, the problem was caused by using an obsolete 2.x version of the aws-eb-cli tools package. Upgrading it to 3.x made the error obvious - building the docker image has failed on AWS.
What I was looking for was running an existing docker image, I found instruction for this scenario at https://aws.amazon.com/blogs/aws/aws-elastic-beanstalk-for-docker/.
Thanks a lot for Nick for asking the right questions which made me realize the obsolete tools package!

Deploying Play 2.3 on production

I have developed a Scala/Play webapp and now I am trying to deploy it on production.
What is the recommended "best way" of doing that?
The documentation mentions only runnig it from play console, which does not seem very robust (in case of machine restarts etc).
There are apporaches to wrap the app into a war file and deploy on Tomcat7 (e.g. play2war), but they do not seem to be actively developed (e.g. there is only beta support for 2.3, the plugin is not available from maven repo etc).
What is the right way of doing this?
If you host the application on Windows then take a look at Yet Another Java Service Wrapper which wraps the application in a Windows service that will keep it running, even after restarts.
If you run it on Linux then take a look at Supervisord and Monit, which monitors the application and starts, restarts and stops it when needed.
See the following links for tutorials:
How do I run a Play Framework 2.0 application as a Windows service?
http://marcovanduijn.blogspot.nl/2011/08/run-play-framework-application-as.html
http://blog.fgribreau.com/2013/09/how-to-make-play-framework-2-work-with.html

Deploying Golang Applications to AWS OPSWORKS

Over the last few months I've become familiar with the AWS OpsWorks deployment process as it pertain to Node.js - deployment for Go seems to be another animal.
From what I've gathered, this is what I need to compile a successful Go deployment:
Install go on the EC2 box
Pull the private repository from GitHub
Pull in all dependencies
Compile the main package for the box's arch
Start the binary with a couple of flags that I use
Everywhere I have read seems to tout the ease of Go deployments because dependencies are included in the binary, but that seems to imply that you are compiling the application in your development environment and pushing that up to the cloud. This doesn't seem like a process that works well across a development team.
https://github.com/crowdmob/chef-golang-web-server-cookbook
I have been attempting to get the Chef Scripts from CrowdMob working, but to no avail. I continue to get errors that look like this:
[2014-08-01T16:08:22+00:00] WARN: Cookbook 'templates' is empty or entirely chefignored at /opt/aws/opsworks/current/merged-cookbooks/templates
What is the proper way to deal with dependencies during deployment?
Are there any established practices for deploying Go onto AWS with Chef?
Use a continuous integration service like CircleCi, Travis or your own setup Jenkins.
On the Continuous integration service then
Add a github post commit hook .
Test / Build the binary
Create the zip file as artifact
At this point you can create an new version on Elastic Beanstalk using the AWS commandline and the zip file created from this version.
venv/bin/aws elasticbeanstalk create-application-version ...
Then just select which version to deploy from the EB dashboard.
For simple services using Chef is overkill IMHO. Docker offers a simple workflow.
Use the Docker container option and then use elastic beanstalk's command-line client to initialize your environment in the project root directory and then you can simply do a 'git aws.push' from the same place.
With the correctly configured Dockerfile in your project and pushed to eb, the EBS' docker container app will pull the correct image with golang installed, then do a go get on your projects dependencies, and then compile and run your app. It sounds way more complicated but it's actually very easy.
Below is a link to a video walkthrough I did for running a simple golang webapp on EBS. The method for uploading the project does not use git. Instead, I zip it up and upload it, but the git method is recommended (and I do it) for automating deployment.
YouTube: How to run a go web app on Amazon's Elastic Beanstalk
I also had some problems to setup a good building process with Elastic Beanstalk and Go.. I don't want to use Docker, and all the people seems to be going on this direction.. so.. you can take a look at this project: https://github.com/battle-arena/heimdall
There you will find a custom setup using the Buildfile and the Procfile.. and I rely on a CI system to build the release package...
Basically I do the following:
Hook the commits to a CI system
On the CI system I run the test and the install.sh if all good
The install.sh will create a build folder and a structure that will be sended to the Elastic Beanstalk with the aws-cli tool
After send to the EB the Buildfile will run the build.sh that will basically extract the compressed package with the proper structure, and run a go get ./... and go build
The Procfile will run the generated binary
I think the result is pretty good, and you can use with any CI tool.

How do I run GWT on a linux server

Sorry for this simple question but I seem not to find any other way than to publish a GWT app to Google App Spot. I'm sure there must be a way to do this.
I've got the development environment working on my local machine but I'd like to publish the solution to my ubuntu server running nginx.
Edit: Just thought of something... maybe I can just deploy the js-code to the ubuntu server? As simple as that? ;)
No you cant just deploy the js-code and html files to an ubuntu server and put it for apache to serve, well... unless your code only outputs hello world that is. Probably your GWT app is calling/using some other Java code that needs to be deployed in tomcat or jboss, is it? If that is the case, ie your GWT is in a war, then yes, just deploy that .war file to any container on any linux box.
Try to copy your .war into a jboss deploy dir.
Deploying to app spot is similar, ie uploading your .war to google. Read more here http://code.google.com/webtoolkit/doc/1.6/DevGuideDeploying.html
Two options:
Run it in Eclipse
Run it with Ant