Starting Redwood Platform Automatically on Solaris

on-site-related topic

Introduced in Solaris 9 and enabled by default in Solaris 10, SMF allows far better fault tolerance and has many other advantages over legacy SVR4 systems. SMF services are identified by their Fault Managed Resource Identifier (FMRI).

Note: With SMF, the service needs to be put in either maintenance or disabled mode if you want to stop it.

The following two files can be used on Solaris systems:

Copy
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='redwoodrc'>
  <service name='application/redwoodrc' type='service' version='1'>
  <single_instance />
    <!-- redwoodrc potentially depends on a database, if the database is running on the same host
         svc:/application/oracle (the name of our Oracle services in this example)
         you may comment the dependency out or change svc:/application/oracle to the fmi
         of the oracle service
    -->
    <dependency name='redwood_oracle' type='service' grouping='require_all'>
      <service_fmri value='svc:/application/oracle' />
    </dependency>
    <exec_method type='method' name='start' exec='/opt/redwood/redwood start' timeout_seconds='60'>
      <method_context>
        <!-- Please change the user and group accordingly -->
        <method_credential user='<Redwood_user>' group='<Redwood_group>' />
      </method_context>
    </exec_method>
    <exec_method type='method' name='stop' exec='/opt/redwood/redwood stop' timeout_seconds='60'>
    </exec_method>
    <instance name='default_redwoodrc' enabled='false' />
    <template>
      <common_name>
        <loctext xml:lang='C'>Redwood Scheduler Startup / Shutdown</loctext>
      </common_name>
    </template>
  </service>
</service_bundle>

For this example, you use the following redwood file:

Copy
#!/bin/bash
#
# (C) Copyright 2006-2023 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 Scheduler.
### END INIT INFO

# Redwood installation path (path to the j2ee directory)
PATHS="/opt/server/redwood"
USER=nobody

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

startInstance()
{
  su -l $USER -c /bin/bash ${PATHS}/j2ee/cluster/server1/bin/start.sh
  echo "Started Redwood"
}

stopInstance()
{
  echo "Stopping Redwood"
  su -l $USER -c /bin/bash ${PATHS}/j2ee/cluster/server1/bin/stop.sh
  timeout=30

  while [ "`ps -ef | grep server1 | wc -l`" -gt 1 -a $timeout -gt 0 ]
  do
    sleep 1
    timeout=`expr $timeout - 1`
  done
  echo "Redwood is stopped"
}

statusInstance()
{
  if [ "`ps -ef | grep server1 | 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 $?

Troubleshooting

SMF will set services in maintenance mode when a problem is detected. The service will fail to start until the maintenance mode is cleared. To check which services are in maintenance mode, run the following command:

Copy
svcs -a

When a service is in maintenance mode, follow these steps to enable it again:

Make sure all associated processes have died:

Copy
svcs -p <FMRI>

Kill any processes that are still running:

Copy
pkill -9 <PID>

Correct the problem that caused the service to fall in maintenance mode.

Clear the maintenance mode flag from the service by running the following command: svcadm clear <FMRI>

Example

Clearing the maintenance mode flag from the redwood service

Copy
svcadm clear application/redwood:default
svcadm enable application/redwood:default

For more information, refer to the manual pages of the following commands svcs, svcadm, svccfg, inetadm.

See Also