Scala start game server in production

I have a Play 2.0 application deployed on EC2 and I run the application with play start and it runs in the background, I can press Ctrl-D and the process will continue to run in the background, but then it dies after that time like (15 or 20 minutes?), don’t know why. I usually exit the ssh session after starting the application, I hope this is not the reason.

+6
source share
4 answers

nohup play start works for me.

+10
source

I use the following script run (on CentOS) for my Play application, it seems to be working fine, it puts it in the background and in its own process group and session, so it is immune to hangs, etc. The advice on the play stage and target/start comes from Guillaume Bort and is the "right way to do it."

 #!/bin/bash # # chkconfig: 2345 98 1 # description: MyApp application # case "$1" in start) su - apps <<'EOF' cd /opt/myapp || exit 1 PATH=/opt/play-2.1.1:$PATH echo "Starting MyApp..." play stage setsid target/start < /dev/null > /dev/null 2>&1 & EOF ;; stop) su - apps <<'EOF' cd /opt/myapp || exit 1 PATH=/opt/play-2.1.1:$PATH echo "Stopping MyApp..." play stop EOF ;; esac 

You can check it for availability:

 ps -e -o user,pid,ppid,pgrp,sid,command | grep -i play 

You will see something like:

 apps 2949 1 2949 2949 java -cp target/staged/* play.core.server.NettyServer target/.. 

The value init (pid 1 ) is its parent and is isolated in its own process group ( 2949 ).

+3
source

I would suggest that you prepare the project deployment binary using the stage command that the activator (previously playing) script accepts. You can run this binary in the background, it can be found in the path that the second command shows in the code below.

 ./activator stage target/universal/stage/bin/project-name & 
+1
source

For the game 2.2.3 ... the game "start -Dhttp.port = 8080" worked for me!

0
source

Source: https://habr.com/ru/post/916508/


All Articles