我如何才能让spring-boot永远在ubuntu上运行? [英] How can I get spring-boot to run forever on ubuntu?

查看:121
本文介绍了我如何才能让spring-boot永远在ubuntu上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 vm 上运行spring-boot,并具有 nginx 的所有请求它.我已经完成了这项工作,但是当我运行时:

I'm trying to run spring-boot on a vm and have nginx proxy all request towards it. I've got this working but when I run:

mvn spring-boot:run

mvn spring-boot:run

我的ssh会话结束,它将停止spring引导实例. (符合预期)

And my ssh session ends, it will stop the spring boot instance. (as expected)

我还尝试添加<executable>配置并将符号 spring-boot jar 链接到服务,如下所示:

I've also tried adding the <executable> config and sym-linking the spring-boot jar to a service, like so:

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

然后符号链接 .jar :

Then symlink the .jar:

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

现在,当我运行该服务时:

Now when I run the service:

sudo /etc/init.d/user_service start

它将注销:

Started [26208]

但是不能运行实际的服务器吗?! 26208 PID也不会显示在我的进程中!

But not run the actual server?! The 26208 PID won't show up in my processes either!

有什么想法吗?是否有永久运行Spring Boot应用程序的替代方法?像节点中的 forever 工具一样?

Any ideas? Is there an alternate way of running a spring boot app forever? Like the forever tool in node?

推荐答案

如果在ubuntu中运行应用程序,则可以使用nohup和&在后台运行您的流程.很简单,希望它能解决您的问题

If you are running you application in ubuntu, you can use nohup and & to run your process in background. It is simple and I hope it will solve your problem

nohup mvn spring-boot:run &

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

这篇关于我如何才能让spring-boot永远在ubuntu上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆