【发布时间】:2016-03-07 02:14:43
【问题描述】:
我尝试按照 here 的说明操作,尝试将 Spring Boot 应用程序作为 init.d 服务运行,但未能成功。
如前所述,我创建了完全可执行的 jar (myapp.jar),并创建了指向 /etc/init.d/myapp 的符号链接。当我运行 java -jar myapp.jar 我可以看到应用程序成功启动。
但是当我尝试使用时
service myapp status 上面写着Not running (process not found)
service myapp start 上面写着Failed to start
文档说“假设您在 /var/myapp 中安装了 Spring Boot 应用程序”我不太明白这一点。我将可执行 jar(通过 Jenkins)复制到 /var/myapp。所以它只包含一个jar文件。这会造成问题吗?
欢迎提出任何建议。
环境:
springBootVersion = '1.3.2.RELEASE'
JDK6 (yes it is)
Ubuntu 12.04
【问题讨论】:
-
您的应用程序尚未注册为服务。因此,您可以使用 service 命令来检查应用程序的状态。有关更多信息,请查看此线程 stackoverflow.com/questions/3922554/…
-
感谢您的回复。但我仍然没有做对。我需要为它编写额外的脚本吗?我引用的spring doc链接中没有提到。那么我应该在哪里使用 $nohup java -jar program.jar & this?
-
其实spring doc不是很明确。使用“服务”时,您还需要执行“systemctl”的步骤。 Debian“服务”命令的官方文档更清晰:wiki.debian.org/systemd/Services 使用spring文档:docs.spring.io/spring-boot/docs/current/reference/html/…
标签: java linux spring spring-boot ubuntu-12.04