[OpenIndiana-discuss] shell script mutex locking or process signaling
Gary Mills
gary_mills at fastmail.fm
Sat Jun 1 15:31:21 UTC 2013
On Sat, Jun 01, 2013 at 02:20:09PM +0000, Edward Ned Harvey (openindiana) wrote:
> > From: Gary Mills [mailto:gary_mills at fastmail.fm]
> >
> > If your method script starts a server process in the background and
> > then immediately exits, it is broken.
>
> Fortunately for me, I don't have that problem. The start & stop
> scripts do indeed stay running until the service has reached a
> running or stopped state. The issue is with regard to concurrency -
> if a service takes a long time to start or stop, or if there's a
> problem with the start or stop, then the ability to launch "stop"
> and have it kill a "start" that's already in progress.
That's where the timeout, set in the manifest, comes into play.
Generally that's sufficient. I suppose, though, that when you have
a service that's slow to start up or shut down, with a necessarily
long timeout, you may become impatient and want a way to do something
manually. A method script could catch a signal. I see a few in
/lib/svc/method that do this:
$ grep trap *
coherence: trap "" SIGHUP
identity-node: trap 'intr=1' 2 3
identity-node: trap 2 3 ;;
x11-server:trap Xserver_ready USR1
x11-server:(trap '' USR1 ; exec /usr/bin/Xserver $CLASSES :$DISPLAY $* &)
You'd only need another command that sent the signal to the method
script. I've never needed such a thing, but I suspect it would work.
> I swear,
> I've seen multiple instances of the script running concurrently
> before, but now I can't reproduce that. At least, it can be run
> multiple times in parallel - manually. If the admin issues "stop"
> while the "start" is still in progress (now that I've added this
> locking etc) then the start script dies gracefully, and the stop
> script does its thing.
--
-Gary Mills- -refurb- -Winnipeg, Manitoba, Canada-
More information about the OpenIndiana-discuss
mailing list