Starting Redwood Platform Automatically with Init

on-site-related topic

You configure Redwood Platform to start automatically on UNIX systems using init by specifying a startup script that is compatible with your platform. There is usually a skeleton available on your platform; consult the platform-specific documentation. Create a script in your UNIX startup scripts location (often /etc/init.d/ or /etc/rc.d/). If the database is running on the same host, check to see in which runlevel it is started, create two symbolic links to your script in that runlevel, one starting with S the other with K, the S and K links should be followed by a number higher than the number of the database startup and shutdown scripts followed by the name redwood, so it starts later and gets stopped before your database gets shut down.

On some systems, like Suse 10, you must enable the service with yast or yast2.

The following example script can be used to start Redwood Platform on UNIX systems using init. Note that you must customize it according to your needs. Change the LUSER environment variable.

On Suse, RedHat, and Oracle Linux systems, you use chkconfig to install the service.

Init Shell Script

Copy
#!/bin/bash
#
# (C) Copyright 2006-2017 Redwood Technology B.V., Houten, The Netherlands.
#
# $Id$
#
###
# IRIX style chkconfig
####
# chkconfig: 2345 19 08
# description: Redwood Startup script
###
# Linux Standard Base Specification 1.3
# Used by insserv and other LSB compliant tools.
### BEGIN INIT INFO
# Provides: scheduler
# Required-Start: $local_fs $autofs $remote_fs $network
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 6
# Short-Description: Start & Stop Scheduler
# Description: Script to start and stop the Redwood.
### END INIT INFO

# Redwood installation path (path to the j2ee directory)
RW_INSTALL="/opt/server/redwood"
LUSER=nobody
SERVER_NUM=1

showUsage()
{
  if [ -z "${1:-}" ]
  then
    echo "Usage: $0 {start|stop|status}"
    exit 0
  fi
}

startInstance()
{
  su -l $LUSER -c /bin/bash ${RW_INSTALL}/j2ee/cluster/server${SERVER_NUM}/bin/start.sh
  echo "Started Redwood"
}

stopInstance()
{
  echo "Stopping Redwood"
  su -l $LUSER -c /bin/bash ${RW_INSTALL}/j2ee/cluster/server${SERVER_NUM}/bin/stop.sh
  timeout=30

  while [ "`ps -ef | grep server[`${SERVER_NUM}`] | wc -l`" -gt 0 -a $timeout -gt 0 ]
  do
    sleep 1
    timeout=`expr $timeout - 1`
  done
  kill `ps -ef | grep server[`${SERVER_NUM}`] | awk '{print $2}'`
  echo "Redwood is stopped"
}

statusInstance()
{
  if [ "`ps -ef | grep server`${SERVER_NUM}` | wc -l`" -gt 1 ]
  then
    echo "Redwood: Running"
  else
    echo "Redwood: Shutdown"
  fi
}

#
# MAIN
#

case $1 in
  start)
    startInstance
  ;;
  stop)
    stopInstance
  ;;
  status)
    statusInstance
  ;;
    *)
    showUsage
  ;;
esac
exit $?

Procedure

Linux

This script is compliant with the Linux Standard Base specification

  1. Adapt the script to your environment and save it to a file named redwood.com-scheduler in the /etc/init.d/ folder.
  2. If the database is on the same host, you must locate the name of the start script for your database and add it to the # Required-Start: section.
  3. Run chmod +x /etc/init.d/redwood.com-scheduler to make the startup script executable.
  4. Run /usr/lib/lsb/install_initd /etc/init.d/redwood.com-scheduler to install the startup script.

Other UNIX

The precise instructions vary from platform to platform; please consult the documentation.

  1. Adapt the above script to your environment and copy it to your startup scripts folder (often /etc/init.d/ or /etc/rc.d/).
  2. If your database runs on the same host, locate the startup script of your database and its symbolic S and K links (usually in /etc/rc<n>, where <n> is the runlevel number).
  3. Create symbolic S and K links in the desired runlevels with a higher number than the database.

See Also