Thursday, January 12, 2017

Play Framework project in production - Building process

We want to deploy our Play project to production environment.

Create a binary version of application

There are two commands that can help you to make a build. Simply run dist (it invokes universal:packageBin) or universal:packageZipTarball in Play console and wait
$ dist
$ universal:packageZipTarball
Result will be a ZIP or TGZ file located in target/universal folder with everything needed for you project (it means you do not need to install SBT or Activator on your server, just pure Java). Once you extract ZIP you will find 2 runner files in bin folder (one for unix and one for windows). Just run it and your server will up
$ path/to/hellow-world/bin/hello-world-app 
[info] play.api.Play - Application started (Prod)
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
Make sure you have rights to run server, sometimes you need to give rights (see example below)
$ chmod +x /path/to/bin/project-name
To run process in background
$ sudo nohup target/universal/stage/bin/eqa-app -Dhttp.port=80 -Dplay.crypto.secret="secret_token_123" /dev/null 2>&1 &

No comments :