Example Unix Broker Startup Script

The following is an example of a simple startup script for the Silver Fabric Broker running on a Linux system.

A Sample Unix Broker Startup Script

#!/bin/sh 
# Startup script for Silver Fabric Broker
# 
# Source function library. 
. /etc/rc.d/init.d/functions 
prog="server" 
DSBASE=/opt/fabric 
JAVA_HOME=/usr/local/java 
export JAVA_HOME 
case "$1" in
    start)
        cd $DSBASE
        ./server.sh start
        ;;
    stop)
        cd $DSBASE
        ./server.sh stop
        ;;
    restart)
        cd $DSBASE
        ./server.sh stop
        ./server.sh start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1 
esac 
exit 0

After creating the above file, place it in /etc/rc.d/init.d/. Your Linux system does not directly run scripts from this directory. Instead, a different directory within /etc/rc.d corresponds to each runlevel of your system. When your system enters a runlevel (for example, during system startup), each script in that runlevel’s associated directory is run and passed the start or stop parameter.

Instead of creating several identical copies of your script, you can create symbolic links in each runlevel directory. Links beginning with K run the script with the stop parameter; those with S run the start parameter. The number at the start of each link dictate the order in which scripts run.

The following is an example of the links created when installing the above script. These links start the Silver Fabric Broker at runlevels 3 and 5 and stop it at runlevels 0, 1, and 6:

lrwxrwxrwx    1 root     root           18 Apr  8 16:26 /etc/rc.d/rc0.d/K02silverfabric -> ../init.d/dsserver 
lrwxrwxrwx    1 root     root           18 Apr  8 16:27 /etc/rc.d/rc1.d/K02silverfabric -> ../init.d/dsserver 
lrwxrwxrwx    1 root     root           18 Apr  8 16:27 /etc/rc.d/rc3.d/S98silverfabric -> ../init.d/dsserver 
lrwxrwxrwx    1 root     root           18 Apr  8 16:27 /etc/rc.d/rc5.d/S98silverfabric -> ../init.d/dsserver 
lrwxrwxrwx    1 root     root           18 Apr  8 16:27 /etc/rc.d/rc6.d/K02silverfabric -> ../init.d/dsserver