设置Derby做为Linux/Windows自启动服务方式运行

一、设置Derby做为Linux自启动服务方式运行

1. 首先在derby包里创建service/linux目录

2. 将下面文件放入其中

derbyservice,用来定义derby的home目录,监听的机器IP和端口

#!/bin/sh

DERBY_HOME=/home/kongxx/temp/db-derby-10.10.1.1-bin
DERBY_HOST=0.0.0.0
DERBY_PORT=1527

case "$1" in
start)
 $DERBY_HOME/bin/startNetworkServer -h $DERBY_HOST -p $DERBY_PORT &
 break
;;
stop)
 $DERBY_HOME/bin/stopNetworkServer -p $DERBY_PORT
 break
;;
status)
 $DERBY_HOME/bin/NetworkServerControl ping -p $DERBY_PORT >/dev/null 2>&1
 if [ "$?" = "0" ]; then
  echo "The derby service is running."
 else
  echo "Cannot find derby service."
 fi
 break
;;
*)
 echo "Usage: /etc/init.d/derbyservice {start|stop|status}"
;;
esac
create_rc.sh

创建linux rc的脚本

#!/bin/sh

SERVICE_DIR=`dirname $0`
SERVICE_PATH=`cd $SERVICE_DIR ; pwd`

cp $SERVICE_PATH/derbyservice /etc/init.d/

remove_rc.sh删除linux rc的脚本

#!/bin/sh

rm -f /etc/init.d/derbyservice

3. 测试
  运行create_rc.sh创建服务
  运行remove_rc.sh删除服务
  运行“/etc/init.d/derbyservice {start|stop|status}”来启动/停止/查看状态。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2d8a9a0c04968d54ad4fda727a2e0b18.html