Converting an rc script to an SMF manifest

I use the ORCA utility to graph various system and application metrics, and have recently run into a few problems. The application periodically crashes for no apparaent reason, and I haven’t had time to debug the issue (once I get a core file I will figure this out). Since I rely on the graphs to trend server and application capacity, I want to ensure that the application gets restarted each time a failure occurs. Since ORCA is running on a Solaris 10 server, I decided to convert the existing start/stop scripts to Solaris 10 SMF manifests. To begin the conversion process, I first created a shell script that would be able to start up ORCA and clear any lockfiles that are present:

$ cat /usr/local/bin/orca.start


if [ -d /var/orca/configs/orcallator.cfg.lock ]
logger -p daemon.notice "Removing orca lockfile"
rm -rf /var/orca/configs/orcallator.cfg.lock

logger -p daemon.notice "Starting orca in daemon mode"

/usr/local/bin/orca -logfile /var/logs/orcallator.log
-daemon /var/orca/configs/orcallator.cfg

Once I verified that the script worked correctly, I created an SMF manifest with a stop and start method and no dependencies:

$ cat orca.xml

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<tservice_bundle type='manifest' name='orca'>


<create_default_instance enabled="true"/>


exec=':kill -15'

After the manifest was created, I used the svccfg ‘validate’ option to verify the structure of the XML document:

$ svccfg validate orca.xml

$ echo ?

If svccfg encounters an error, it will display an error on the console, and return a non-zero return code. If the XML document validates, the svccfg ‘import’ option can be used to import the manifest into the SMF repository:

$ svccfg import orca.xml

Once the manifest has been imported into the SMF repository, the svccfg ‘listprop’ option can be used to display the service’s properties:

$ svccfg -s application/orca listprop

start method
start/exec astring /opt/data/orca/scripts/orca.start
start/timeout_seconds count 0
start/type astring method
stop method
stop/exec astring ":kill -15"
stop/timeout_seconds count 3
stop/type astring method

All of this took me about 15 minutes, and now when ORCA crashes SMF restarts the process, which generates the following messages in the system logfile:

Nov 9 11:56:03 winnie root: [ID 702911 daemon.notice] Removing orca lockfile
Nov 9 11:56:03 winnie root: [ID 702911 daemon.notice] Starting orca in daemon mode

The SMF team did an awesome job with this!!

This article was posted by Matty on 2005-11-12 11:18:00 -0400 -0400