我在我的 Ubuntu 机器上安装了 virtuoso 的开源版本。我面临的问题是,每次重新启动机器时,我都必须手动重新启动 virtuoso。有什么方法可以让我的机器自动启动 virtuoso?就像,我在另一个端口安装了tomcat,我不需要在重启我的机器后重启Apache。有谁知道我可以在哪里进行更改以解决此问题。谢谢
2 回答
it is necessary to handle start and also stop of virtuos a possible way: (as user running virtuoso) create bin folder in home of user that runs virtuoso and add following scripts
virtuosoStart.sh
DBDIR=/vol0/virtuosodb
VIRTUOSO_BIN=/opt/virtuoso7/bin/
export PATH=$VIRTUOSO_BIN:$PATH
cd $DBDIR
virtuoso-t
virtuosoStop.sh
#!/bin/bash
VIRTUOSO_BIN=/opt/virtuoso7/bin/
${VIRTUOSO_BIN}isql-v 1111 dba dba -K
please change DBDIR and VIRTUOSO_BIN according to you environment
(as root, "sudo su" or add sudo before every command ) Now is necessary to make script that accept start and stop parameter in folder /etc/init.d .
cp skeleton virtuoso
chmod a+x virtuoso
you can delet eunnecessary functions and implement start stop and status operation following way:
DESC="virtuoso server"
NAME=virtuoso
DAEMON=/opt/virtuoso7/bin/virtuoso-t
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
DBDIR=/vol0/virtuosodb
PIDFILE=${DBDIR}/virtuoso.lck
SCRIPTNAME=/etc/init.d/$NAME
USER=ubuntu
START_SCRIPT=/home/${USER}/bin/virtuosoStart.sh
STOP_SCRIPT=/home/${USER}/bin/virtuosoStop.sh
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
su -l $USER -c $START_SCRIPT
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
su -l $USER -c $STOP_SCRIPT
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
if [ -f $PIDFILE ] && ps -p$(cut -d "=" -f 2 ${PIDFILE} ) > /dev/null;then
log_success_msg "$NAME is running"
exit 0
else
log_failure_msg "$name is not running"
exit 1
fi
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
exit 3
;;
esac
now is necessay to add links to the script to appropriate /etc/rc.x folders. You can do it manually or better way is by :
update-rc.d virtuoso defaults
hope it helps and good luck
btw: you can add check if the virtuoso is already running to the start part of the init script
write a script like:
#!/bin/bash
sudo /usr/virtuoso-6.1.7/bin/virtuoso-t -fd +configfile /usr/virtuoso-6.1.7/bin/virtuoso.ini
(or any other configuration) save the script somewhere
enter the following into /etc/rc.local
openvt -s /path/to/your/script
after a restart this will automatically start your script in a new backround terminal (or what other term its called) usually after CTRL + ALT + F7 (your desktop) -> CTRL + ALT + F8
I hope I remembered this correctly and documented all steps (it's been a while).
Greetings