2016-06-10 66 views
1

春季啓動有一個方便的功能,這將嵌入的init.d的Starup腳本轉換成可執行的JAR文件,如果你配置Maven插件可以這樣做: http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html#deployment-install春天啓動的應用程序內嵌的init.d腳本沒有啓動重新啓動

因此,我正在使用上述方法在Centos 6.6中「安裝」Spring Boot應用程序(可執行的胖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」手動啓動服務,並且它會恢復,但它不會在啓動時自動啓動。

任何想法? 謝謝

回答

2

問題解決了。原來是路徑問題和我的錯。應用程序所在的路徑是一個在啓動時不可用的掛載目錄。