Spring Boot有一个方便的功能,如果您配置maven插件,它会将init.d starup脚本嵌入到可执行jar中:http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html#deployment-install
因此,我使用上述方法在Centos 6.6中“安装”Spring Boot应用程序(可执行胖 jar )作为服务 .
到现在为止还挺好 . 我创建了一个指向jar的链接并设置了权限:
sudo ln -s /path/to/myapp.jar /etc/init.d/my-service
sudo chmod 0755 /etc/init.d/my-service
我可以成功启动应用程序:
sudo service my-service start
但是,我希望应用程序在启动时启动,因此我使用chkconfig实用程序:
sudo chkconfig --add my-service
sudo chkconfig my-service on
这些命令没有错误,但是当我重新启动Centos时,服务不会自动启动 . 运行:
sudo service my-service status
说明:
Not running
运行:
chkconfig --list my-service
说明:
my-service 0:off 1:off 2:on 3:on 4:on 5:on 6:off
一切看起来都不错,但它还没有开始 . 此时我可以通过“sudo service my-service start”手动启动服务并重新启动,但它不会在启动时自动启动 .
有任何想法吗?谢谢
1 回答
问题解决了 . 原来是路径问题和我的错 . 应用程序所在的路径是安装目录,该目录在引导时不可用 .