Reputation: 63
I'm using Play Framework 2.6. After creating the production build zip using
dist
In the play console, I'm using this code to launch the application on the server
my-first-app-1.0/bin/my-first-app -Dconfig.file=/path/to/config -Dplay.http.secret.key=$APP_SECRET
this launches a console that ends with :
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
after which my server proceeds to work perfectly fine. However, closing the console (ctrl+C
) or exiting the terminal window; ctrl+d
does nothing either. What am I missing here?
update
So I looked through the logs, but exactly nothing happens before the server shuts down.
2018-04-20 02:24:36,207 [INFO] from application in application-akka.actor.default-dispatcher-28 - <some benign application log>
2018-04-20 02:36:25,881 [INFO] from play.core.server.AkkaHttpServer in Thread-5 - Stopping server...
2018-04-20 02:36:25,940 [INFO] from application in application-akka.actor.default-dispatcher-41 - Shutting down connection pool.
Of course, during this time my terminal had also disconnected (again, it seems to me that the way I'm starting my server is wrong, please advise.)
Upvotes: 0
Views: 601
Reputation: 63
My problem seemed to indeed be that Play was quitting because of the console.
I managed to solve this by starting play using nohup:
nohup ~/myApp/bin/myApp -Dconfig.file=/path/to/conf -Dplay.http.secret.key=$SECRET &
Upvotes: 0
Reputation: 1789
I need to say I don't have super senior level experience; but couple of things here; regarding the deployment of the Play application:
Standalone app on a physical/virtual server: If you want to deploy your application on bare metal/server instance/etc. without any other front facing applications, then you need to run your application on port 80
not 9000
. Because you want your users to go to example.com
and not example.com:9000
.
Standalone app behind http server on physical/virtual server: You could use front end http server (e.g., Nginx) and run your Play application behind it. This way you can use the front-end http server as a bridge to your application. In fact, you can use it as a load balancer to multiple instances of the an application.
Dockerizing your application: This time, you make a docker image from your application, and put that image into a container management system (e.g., Kubernetes). Then you need to create a load balancer that directs the traffic from the public Internet to your container management system.
Cloud Service Deployment: There are also cloud service deployments. For example, in Heroku, you use its plugin, as a dependency, within your build.sbt
; and then you push your app into its structure, where the rest is being taken care of.
Number three is obviously an overkill for small teams; but it could be the solution to your problem where; you don't want to ssh
into your server and deploy your Play application. The same with number four. For number one and two, you could however create a shell script that is executed based on a certain criteria (when your server is rebooted) to execute the Play related script; to bring up the application.
Upvotes: 1