最近项目用到spring boot,看了官方文档,可以把spring boot的jar包安装为一个service,直接用service serviceName start/stop/status/restart来控制。还可以设置开机自动启动,这样可以防止进程被杀掉。
可以:
1. Starts the services as the user that owns the jar file
2. Tracks application’s PID using /var/run/appname.pid
3. Writes console logs to /var/log/appname.log
但是按照教程配置之后service myapp start启动时一直报Unit myapp.service not found。找了很久才找到解决办法。
打包
用maven打包举例,plugin加上参数
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<