简体   繁体   English

将Spring Boot Web应用程序作为服务部署到Ubuntu

[英]Deploying a Spring Boot web application as a service to Ubuntu

I have a Spring Boot app that I want to start using System V Init . 我有一个Spring Boot应用程序,我想开始使用System V Init My jar file is in /var/my-app/my-app-0.0.1-SNAPSHOT.jar . 我的jar文件位于/var/my-app/my-app-0.0.1-SNAPSHOT.jar So, I created a symbolic link using the command below 因此,我使用以下命令创建了符号链接

sudo ln -s /var/my-app/my-app-0.0.1-SNAPSHOT.jar /etc/init.d/my-app-0.0.1-SNAPSHOT

without any issue. 没有任何问题。 However, when I try 但是,当我尝试

sudo service my-app-0.0.1-SNAPSHOT start

I get the error: 我收到错误:

/etc/init.d/my-app-0.0.1-SNAPSHOT: 1: /etc/init.d/myapp-0.0.1-SNAPSHOT: Syntax error: Unterminated quoted string

Does anyone have an idea what I'm doing wrong? 有人知道我在做什么错吗? Thanks. 谢谢。

What does a symbolic link have to do with the service? 符号链接与服务有什么关系? Nothing :) 没有 :)

You will first have to define the Upstart script (in case of Ubuntu 14.04 ), it is in /etc/init/ and ending in .conf. 首先,您必须定义Upstart脚本(对于Ubuntu 14.04而言),该脚本位于/ etc / init /中,并以.conf结尾。 ( http://upstart.ubuntu.com/cookbook/ ) http://upstart.ubuntu.com/cookbook/

# <service name>.conf
start on filesystem
exec /usr/bin/java -jar /path_to/program

in case of Ubuntu 16.06+ (you can find nice article here ) 如果是Ubuntu 16.06+(您可以在此处找到不错的文章)

sudo vim /etc/systemd/system/my-webapp.service

Then you can run it as: 然后,您可以将其运行为:

sudo service <your service name> start

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM