0

I have a media server running on OpenSolaris that is using Coherence to serve the media to the network. Sometimes I am having trouble on startup as the Coherence service fails to start because the lock file still exists (it was not cleaned up properly).

I want to know what is the best/neatest/most official way to delete this file on startup before the Coherence service attempts to start.

I thought about writing a quick script and putting it in /etc/rc3.d/ but I have read that OpenSolaris doesn't necessarily run scripts from that location.

2 Answers 2

0

Solaris uses SMF for managing services, but still supports the rc structure. Which way is Coherence started on your system? I would say that you need to use the same method for your lock-deleting script.

For documentation on the Solaris Service Management Facility (SMF) see this.

From that page:

Note that svcadm should only be used for SMF services -- legacy rc script-controlled services work the same as in past releases.

And:

Services that are started by traditional rc scripts (referred to as legacy services) will generally continue to work as they always have. They will show up in the output of svcs(1), with an FMRI based on the pathname of their rc script, but they can not be controlled by svcadm(1M). They should be stopped and started by running the rc script directly.

As mentioned in the "Notable Changes" section, rc scripts may not run at exactly the same point in boot as they had in earlier versions of Solaris. In particular, scripts which depend on running before certain Solaris-provided rc scripts may encounter problems. The vast majority of scripts should continue to work without any trouble, though.

Coherence (Open)Solaris Installation Guide

1
  • Thanks for the reply. I am using Coherence as per the guide and using svcadm to enable/disable it etc. I've also found another solution which I've added an answer for. Oct 14, 2009 at 15:09
0

Just for information for future people.

I fixed my problem by modifying the coherence.sh script (which gets used by svcadm to start/stop the server), adding code to detect if the server was running and deleting the log file there if it was not.

The code inserted:

check() {
        if [ -f ${LOCKFILE} ]; then
            pgrep -f /usr/bin/$PROGNAME &> /dev/null
            RETVAL=$?
            [ ${RETVAL} -ne 0 ] && rm -rf ${LOCKFILE}
            echo ${RETVAL}
        fi
        return 0
}

Then I called this function from the beginning of the start() function and just before returning in the stop() function.

This will check if the executable is running and delete the log file if it is not. Seems to work fine and I haven't had any problems with it.

1
  • &> /dev/null would only work in bash. >/dev/null 2>& 1 works in any POSIX shell. Aug 4, 2012 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .