Scala start Play server in production

前端 未结 4 1859
無奈伤痛
無奈伤痛 2020-12-03 06:03

I have a Play 2.0 app deployed on EC2 and I start the app with play start and it runs in the background, I can hit Ctrl-D and the process will cont

相关标签:
4条回答
  • 2020-12-03 06:35

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

    0 讨论(0)
  • 2020-12-03 06:37

    I would suggest that you prepare the project deployment binary by using the stage command that the activator (formerly play) script takes. You can run that binary in the background, it can be found in the path which the second command in the code below shows.

    ./activator stage
    target/universal/stage/bin/project-name &
    
    0 讨论(0)
  • 2020-12-03 06:48

    nohup play start works for me.

    0 讨论(0)
  • 2020-12-03 07:00

    I'm using the following startup script (on CentOS) for my Play app, seems to work fine, it puts it in the background and in its own process group and session so it's immune to hangups etc. The tip about play stage and target/start comes from Guillaume Bort and is "the proper way of doing 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 verify it's isolated with:

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

    You'll see something like:

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

    Meaning init (pid 1) is its parent and it's isolated in its own process group (2949).

    0 讨论(0)
提交回复
热议问题