java - 如何使用 upstart 正确启动 gradle 生成的脚本?

标签 java linux bash gradle upstart

我正在尝试将 Java 应用程序部署到 VPS 上。我正在使用带有“应用程序”插件的 Gradle 构建系统。我希望应用程序随服务器一起启动。

在部署过程中,我运行 ./gradlew install 来准备运行脚本。直接运行时,它们可以正常工作。

我用了http://www.whiteboardcoder.com/2014/02/ubuntu-upstart-job-with-java-jar.html作为 Upstart 配置的基础:

description "the test server"
start on runlevel [2345]
stop on runlevel [!2345]

expect fork

script
   cd /opt/testserver/
   exec ./build/install/testserver/bin/testserver
end script

但是 upstart 在运行 start testserver 后报告的 PID 与使用 ps 发现的不同。我的猜测是,原因是生成脚本的最后一行:

exec "$JAVACMD""${JVM_OPTS[@]}"-classpath "$CLASSPATH"mypackage.TestServer"$@"

因此,Upstart 无法停止该应用程序。有没有办法让 upstart 看到正确的 PID?

最佳答案

看起来这里没有 fork ,所以您应该尝试删除 expect fork 位。

关于java - 如何使用 upstart 正确启动 gradle 生成的脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26475176/

相关文章:

Android NDK-arm-linux-androideabi-g++ : not found

python - 如何匹配不同目录中的文件名?(bash或python)

arrays - rsync如何用空格排除数组中的所有内容?

java - Spring JDBC 的事务处理不适用于 Google Guice

c++ - 在 CentOS 6 x64 上构建的应用程序的 32 位版本在较新的 Linux 上启动时会在 `dl_iterate_phdr` 异常期间崩溃

java - ClassNotFoundException 使用Processing's PApplet 和 Arduino 工具

linux - wget——未知字符

bash - 命令中的 Shell 变量替换

java.lang.StringIndexOutOfBoundsException : String index out of range: 12 in java

java - 应用程序关闭后 MediaPlayer 继续播放