关机不会关闭带有 db derby 服务的计算机

关机不会关闭带有 db derby 服务的计算机

我按照此说明设置了服务数据库德比全新安装 Ubuntu 12.10 - 17. apache db derby

#!/bin/bash
#
# Startup script for Derby
### BEGIN INIT INFO
# Provides:          derby
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     91 2 3 4 5
# Default-Stop:      20 0 1 6
# Short-Description: Start Apache Derby DB at boot time.
# Description:       Provides a small simple java based DB.
### END INIT INFO#
# chk con fig: 345 94 16
# description: Derby startup script
# to enable on bootup on redhat "chkconfig --level 35 derby on"
# to enable on bootup on debian "update-rc.d derby defaults" or the
# slightly longer (but better run levels) "update-rc.d derby start 91 2 3 4 5  . stop 20 0 1 6 ."

# see http://blog.rimuhosting.com/2009/09/30/one-java-init-script/

HOMEDIR=/opt/db-derby
DERBY_USER=derby
APPNAME=Derby

# see http://www.vogella.com/articles/ApacheDerby/article.html  for startUp Options
RUNCOMMAND="bin/startNetworkServer  -h 0.0.0.0"
STOCOMMAND=bin/stopNetworkServer
LOGFILE=/var/log/derby.log
...

当德比正在进行时

service derby status
Derby ( PIDs 1503  ) is running.

我无法关闭计算机。关机在登录屏幕结束。

当我停止德比战

sudo service derby stop

然后我就可以正常关闭计算机了。

我应该怎么做才能在运行服务 db derby 的情况下正确关闭计算机?

答案1

[解决了]

我编写了自己的服务脚本。现在 db derby 可以按预期工作。

将 Ubuntu 12.04 下的 Apache DB Derby 设置为服务。

将文件复制derby到目录/etc/init.d/

#!/bin/bash
#
# Startup script for Derby
#
# description: Derby startup script
# to enable on bootup on debian "update-rc.d derby defaults" or the
# to disable on bootup on debian "update-rc.d derby remove"


DBDIR=/var/db/derby
APPCOMMAND=/opt/db-derby-10.9.1.0-bin/bin/NetworkServerControl

start() {
    echo -n "Derby Starting: "
    cd $DBDIR
    sudo -u derby mv derby.2.log derby.3.log
    sudo -u derby mv derby.1.log derby.2.log 
    sudo -u derby mv derby.log derby.1.log 
    sudo -u derby $APPCOMMAND start -h 0.0.0.0 &
    sudo -u derby sleep 3
    sudo -u derby chmod 644 derby.log 
}

stop() {
echo -n $"Derby Shutting down: "
    $APPCOMMAND shutdown &
}

status() {
    echo "Derby has status: "
    $APPCOMMAND ping
}

case "$1" in
    start)
        start
        ;;
     stop)
        stop
        ;;
     restart)
        stop
        sleep 3
        start
        ;;
     status)
        status
        ;;
     *)
        echo "Usage: $0 {start|stop|restart|status}"
     exit 1
esac

exit $?

然后通过命令将脚本安装为服务update-rc.d derby defaults

通过命令卸载脚本update-rc.d derby remove

将目录设置/var/db/derby为所有者derby

sidlo64@ubuntu:/var/db$ ls -al
drwxr-xr-x  3 root  root  4096 srp 24 16:48 .
drwxr-xr-x 16 root  root  4096 srp 26 06:45 ..
drwxr-xr-x  3 derby derby 4096 srp 24 22:28 derby

用于手动停止数据库的使用service derby stop

对于手动启动数据库使用sudo service derby start

答案2

也许这只是一个错误,可以通过重新安装 gnome-keyring 或 Derby 服务来修复,请尝试从终端正常关机:

sudo halt

或者强制关机

sudo shutdown -h now

此外,您可以制作一个小脚本,首先停止 derby 服务,然后执行关机操作。

相关内容