gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 02:21:43 29 4
gpt4 key购买 nike

我有一个 Spring Boot 应用程序,我想开始使用 System V Init 。我的 jar 文件位于 /var/my-app/my-app-0.0.1-SNAPSHOT.jar 。因此,我使用下面的命令创建了一个符号链接(symbolic link)

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

没有任何问题。然而,当我尝试时

sudo service my-app-0.0.1-SNAPSHOT start

我收到错误:

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

有人知道我做错了什么吗?谢谢。

最佳答案

符号链接(symbolic link)与服务有什么关系?没什么:)

您首先必须定义 Upstart 脚本(对于 Ubuntu 14.04 ),它位于/etc/init/中并以 .conf 结尾。 (http://upstart.ubuntu.com/cookbook/)

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

如果是 Ubuntu 16.06+(你可以找到不错的文章 here )

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

然后你可以运行它:

sudo service <your service name> start

希望有帮助。

关于java - 将 Spring Boot Web 应用程序作为服务部署到 Ubuntu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48401930/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com