提问者:小点点

如何让spring-boot在ubuntu上永远运行?


我正在尝试在vm上运行spring-boot并让nginx代理所有对它的请求。我已经得到了这个工作,但是当我运行时:

mvn spring-boot:运行

并且我的ssh会话结束,它将停止Spring Boot实例。(符合预期)

我还尝试添加

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
     <configuration>
           <executable>true</executable>
     </configuration>
</plugin>

然后符号链接.jar:

sudo ln -s /var/users-java/target/user-0.0.1-SNAPSHOT.jar /etc/init.d/user_service

现在当我运行服务时:

sudo /etc/init.d/user_service start

它将注销:

Started [26208]

但不运行实际的服务器?!26208PID也不会出现在我的进程中!

有什么想法吗?有没有其他方法可以永远运行Spring Boot应用程序?比如node中的永远工具?


共3个答案

匿名用户

如果您在ubuntu中运行应用程序,您可以使用nohup和

nohup mvn spring-boot:run &

http://www.cyberciti.biz/tips/nohup-execute-commands-after-you-exit-from-a-shell-prompt.html

匿名用户

要在注销后运行命令,您可以使用nohup命令。

nohup代表“无挂断。”nohup是一个忽略挂断信号的POSIX命令。按照惯例,挂断信号是终端警告相关进程注销的方式。

https://en.wikipedia.org/wiki/Nohup

http://linux.101hacks.com/unix/nohup-command/

你的命令看起来有点像

nohup mvn spring-boot:run &

匿名用户

sudo mvn spring-boot: start以分离后台模式启动项目,即使关闭终端也能运行。可以使用sudo mvn spring-boot停止:停止