Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework 2.1.1 Deployment Issues

So, I'm trying to deploy my very simple Play Framework 2.1.1 app but whenever I pass flags through the command line for port and to apply database evolutions, they are ignored.

For example:

sudo play start -Dhttp.port=80 -DapplyEvolutions.default=true

Using this command, the server will not start. Both the port and applyEvolutions=true flags are ignored completely and it throws this error:

[warn] play - Your production database [default] needs evolutions! [warn] play - Run with -DapplyEvolutions.default=true if you want to run them automatically (be careful) Oops, cannot start the server. @6elhl9mca: Database 'default' needs evolution!

I've tried everything I can think of to no avail. Using Play Run on my local machine works fine, no issues. The server is running Ubuntu 12.04. All the proper drivers and connection strings are present and tested, database is running, everything is working without issue except the Play Framework.

like image 651
Michael Hawkins Avatar asked Jun 24 '13 20:06

Michael Hawkins


People also ask

What is activator in play framework?

The activator command can be used to create a new Play application. Activator allows you to select a template that your new application should be based off. For vanilla Play projects, the names of these templates are play-scala for Scala based Play applications, and play-java for Java based Play applications.

Is Play framework asynchronous?

Internally, Play Framework is asynchronous from the bottom up. Play handles every request in an asynchronous, non-blocking way. The default configuration is tuned for asynchronous controllers.

Why play framework is used?

Play Framework makes it easy to build web applications with Java & Scala. Play is based on a lightweight, stateless, web-friendly architecture. Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.


2 Answers

Either

play "start -Dhttp.port=80 -DapplyEvolutions.default=true"

or

play dist

then, unzipping and running the generated start script,

./start -Dhttp.port=80 -DapplyEvolutions.default=true

will work.

like image 94
James Roper Avatar answered Oct 06 '22 03:10

James Roper


Ok, so I didn't really find a solution for this, but I found a workaround. This isn't anywhere in the Play Framework 2.x documentation (yet), so I figure I'll put it here in case someone else gets stuck:

Putting applyEvolutions.default=true into application.conf DOES work, and will make database evolutions apply automatically. The command line argument -DapplyEvolutions.default=true DOES NOT work and is ignored for reasons unknown.

Putting http.port=80 into application.conf DOES NOT work. The command line argument -Dhttp.port=80 also DOES NOT work for setting the port number to run on.

So, to set the port number use this command instead:

play "start 80" or play "run 80" (use double quotes exactly as shown).

For some reason when the port command is written exactly as above in double quotes, the port number to run on is set properly.

This is not found in the framework documentation anywhere. I'd create another pull request to add it, but the last issue I solved for this framework (database encryption) was denigrated as being a "limited, niche use case" only and the documentation update was thus denied. I may still try anyway.

Hope this helps someone.

like image 21
Michael Hawkins Avatar answered Oct 06 '22 01:10

Michael Hawkins