7

我在 EC2 上部署了一个 Play 2.0 应用程序,我启动该应用程序play start并在后台运行,我可以点击Ctrl-D,该进程将继续在后台运行,但一段时间后它会死掉(15 或 20 分钟?),不知道为什么。我通常在启动应用程序后退出 ssh 会话,我希望这不是原因。

4

4 回答 4

10

nohup play start为我工作。

于 2012-05-24T08:17:19.037 回答
3

我正在为我的 Play 应用程序使用以下启动脚本(在 CentOS 上),似乎工作正常,它将它放在后台以及它自己的进程组和会话中,因此它不受挂断等的影响。关于play stagetarget/start来自Guillaume的提示Bort and 是“正确的做法”。

#!/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

您可以通过以下方式验证它是否已隔离:

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

你会看到类似的东西:

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

含义init(pid 1) 是它的父进程,它被隔离在自己的进程组 ( 2949) 中。

于 2013-04-26T17:04:46.947 回答
1

我建议您使用 activator(以前的 play)脚本使用的 stage 命令准备项目部署二进制文件。您可以在后台运行该二进制文件,它可以在下面代码中的第二个命令显示的路径中找到。

./activator stage
target/universal/stage/bin/project-name &
于 2014-09-15T16:46:34.940 回答
0

对于 play 2.2.3 ... play "start -Dhttp.port=8080" 为我工作!

于 2015-06-03T03:16:55.823 回答