我已经为 spring boot 可执行文件 jar 创建了一个符号链接(symbolic link),并且我能够启动该应用程序。我想自定义日志路径、pid 文件夹等。 通过自定义启动 this script .
但我找不到存储自定义脚本的位置以及如何将其链接到可执行应用程序 jar。你能帮忙吗?
最佳答案
创建一个名为 your-app.service 的脚本,将此脚本放在/etc/systemd/system 目录中。
作为 systemd 服务安装,使用 Java 系统属性(VM 参数):
[Unit]
Description= Spring Boot App
After=syslog.target
[Service]
User=myapp
ExecStart=java -Dspring.application.name=example -Dlogging.file=/opt/spring-boot-app/log/app.log -Dspring.pid.file=/opt/spring-boot-app/app.pid -jar /opt/spring-boot-app/app.jar
SuccessExitStatus=200
[Install]
WantedBy=multi-user.target
或者通过程序参数传递:
java -jar /opt/spring-boot-app/app.jar --spring.application.name=example --logging.file=/opt/spring-boot-app/log/app.log --spring.pid.file=/opt/spring-boot-app/app.pid
logging.file= # Log file name (for instance,
myapp.log
). Names can be an exact location or relative to the current directory.spring.pid.file= # Location of the PID file to write (if ApplicationPidFileWriter is used).
关于java - 如何将自定义脚本链接到 spring boot jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53451348/