fenqing 2019-06-26
最近帮助一个客户部署了一个Apache Servicemix环境。
客户提出,能不能让Servicemix开机启动。这样,如果机器出现了什么问题,重启一下就好了。不需要让运维人员知道如何操作Servicemix。
当然可以。需求合理,没有拒绝的理由。
但是实际操作的时候,试过在init.d目录下加脚本,在rc.local中加命令行。在网上也找了好几个方法,均告失败,也没看到任何错误。原以为设置个开机启动,和玩似的,结果被机器玩了。
不过,功夫不负有心人,终于还是找到了办法。
因为servicemix其实就是一个开源大礼包,把几个apache的开源软件组装在一起拼凑而成。运行时环境是Karaf。所以,第一眼在karaf下看到官方的开机启动方案时,眼前一亮。觉得这个方法应该可行。结果一试,果然可以。
操作步骤也非常简单,摘抄如下(不过,还是去官网看一下更靠谱,网址:https://karaf.apache.org/manu...):
Installation Apache Karaf Service Wrapper is an optional feature. You have to install the "Service Wrapper" installer first. In the console: karaf@root()> feature:install service-wrapper Now, you have the wrapper:install command, to "register" Apache Karaf as service/daemon on your system: karaf@root()> wrapper:install --help DESCRIPTION wrapper:install Install the container as a system service in the OS. SYNTAX wrapper:install [options] OPTIONS -d, --display The display name of the service. (defaults to karaf) --help Display this help message -s, --start-type Mode in which the service is installed. AUTO_START or DEMAND_START (Default: AUTO_START) (defaults to AUTO_START) -n, --name The service name that will be used when installing the service. (Default: karaf) (defaults to karaf) -D, --description The description of the service. (defaults to ) The wrapper:install command detects the running Operating Service and provide the service/daemon ready to be integrated in your system. For instance, on a Ubuntu/Debian Linux system: karaf@root()> wrapper:install Creating file: /opt/apache-karaf-4.0.0/bin/karaf-wrapper Creating file: /opt/apache-karaf-4.0.0/bin/karaf-service Creating file: /opt/apache-karaf-4.0.0/etc/karaf-wrapper.conf Creating missing directory: /opt/apache-karaf-4.0.0/lib/wrapper Creating file: /opt/apache-karaf-4.0.0/lib/wrapper/libwrapper.so Creating file: /opt/apache-karaf-4.0.0/lib/wrapper/karaf-wrapper.jar Creating file: /opt/apache-karaf-4.0.0/lib/wrapper/karaf-wrapper-main.jar Setup complete. You may wish to tweak the JVM properties in the wrapper configuration file: /opt/apache-karaf-4.0.0/etc/karaf-wrapper.conf before installing and starting the service. Ubuntu/Debian Linux system detected: To install the service: $ ln -s /opt/apache-karaf-4.0.0/bin/karaf-service /etc/init.d/ To start the service when the machine is rebooted: $ update-rc.d karaf-service defaults To disable starting the service when the machine is rebooted: $ update-rc.d -f karaf-service remove To start the service: $ /etc/init.d/karaf-service start To stop the service: $ /etc/init.d/karaf-service stop To uninstall the service : $ rm /etc/init.d/karaf-service