Prerna Rawat Prerna Rawat - 2 months ago 106
Java Question

Steps to deploy play framework application to production environment?

I got stuck in the steps to deploy the

play-java
application to standalone server. I am using
Ubuntu
instance running on
Ec2
machine. After reading the official documentation I followed these steps:


  • Install
    typesafe activator
    to
    $Home/activator

  • Copy my project folder to
    $Home/activator/projects
    using
    Jenkins

  • Run
    cd $Home/activator/projects/project

  • Run
    dist
    command. It generate the project sh file

  • Run
    cd $HOME/activator/projects/sample/target/universal
    . It shows me three things i.e.
    sample-1.0.zip
    ,
    tmp
    .

  • Run
    unzip sample-1.0.zip

  • Run
    cd $Home/activator/sample/target/universal/sample-1.0/bin
    . It shows me two scripts i.e.
    sample
    (for mac and linux) and
    smaple.bat
    (for windows).



Now, I tried to run this command as documentation says:
sample-1.0/bin/sample -Dplay.crypto.secret="abcdefghijk"
but it got stuck and shows nothing except a prompt on terminal.

What next steps are required to run the application in
daemon
mode. So that server will continue to run always?

Another question is why do I need to follow these steps because just after copying the project I can easily run
activator run
command to
sample
folder to run the server.

EDIT-1



Now I am getting
Error: Could not find or load main class play.core.server.ProdServerStart
while running
sample -Dplay.crypto.secret="abcdefghijk"
command

Answer

Play Framework modes

Play like other frameworks can run in different modes because we are usually like to run our program in different situation and these situations need their configuration. Production is one of play modes. In this mode as the name suggested we are ready to deploy our application where user can use.As a result requirements are different.

Some common configuration in Production mode :

  • We are confining https
  • Using production data base not testing one
  • Play doesn't show errors
  • Play framework run as long term process and if you are log out of your server your application will run
  • If your app fails Play will clone another application and run that so your app run forever except you turn it off.
  • and so on (it is based on your Production config file)

Your answer :

If you just want to test your app in remote server and see what happened, it's okay to use activator run this command runes Play app in development mode and application will killed if you exit or log off (error will shows up and so on). But if you want to use your app for Production it is necessary to run all of these steps.

Comments