From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/1967 Path: news.gmane.org!not-for-mail From: Earl Chew Newsgroups: gmane.comp.sysutils.supervision.general Subject: svwaitup races with sv Date: Sun, 19 Jul 2009 10:14:31 -0700 Message-ID: <4A635477.6030503@agilent.com> References: <8F9355C5-C168-4AD7-8B6C-502416E7EECC@zoy.org> <94175859-2733-4ACF-85E9-DD5FF627F23B@zoy.org> <17A739BC-94BA-4611-A523-6978934F0D61@zoy.org> <4A633321.1060207@agilent.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1248023745 6566 80.91.229.12 (19 Jul 2009 17:15:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jul 2009 17:15:45 +0000 (UTC) To: supervision@list.skarnet.org Original-X-From: supervision-return-2202-gcsg-supervision=m.gmane.org@list.skarnet.org Sun Jul 19 19:15:38 2009 Return-path: Envelope-to: gcsg-supervision@gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by lo.gmane.org with smtp (Exim 4.50) id 1MSZz6-0005Dg-BX for gcsg-supervision@gmane.org; Sun, 19 Jul 2009 19:15:36 +0200 Original-Received: (qmail 28274 invoked by uid 76); 19 Jul 2009 17:16:51 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 28266 invoked from network); 19 Jul 2009 17:16:50 -0000 User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) In-Reply-To: <4A633321.1060207@agilent.com> X-OriginalArrivalTime: 19 Jul 2009 17:18:37.0578 (UTC) FILETIME=[F40746A0:01CA0894] X-Scanned-By: MPP/Clamd http://www.messagepartners.com X-Scanned-By: MPP invoked on aglcosbs01 Xref: news.gmane.org gmane.comp.sysutils.supervision.general:1967 Archived-At: The script below generates the following output: > down: ./svc: 0s > svwaitup: warning: ./svc: is down. > .... WaitUp 1 > Try again > run: ./svc: (pid 8496) 2s, normally down, want down It illustrates a race between runsv/sv and svwaitup. Commenting out the "touch svc/down" leads to other strange results like: > run: ./svc: (pid 8651) 0s > svwaitup: warning: ./svc: unable to change directory: file does not exist > .... WaitUp 1 > Try again > run: ./svc: (pid 8651) 4s, want down The key is that sv(8) writes its command and simply exits. There is no way to determine if the command has actually been acted upon. For example, the following appears to synchronise ok but is a bit clunky: rm svc/supervise/pid ../command/sv once ./svc while [ -e svc/supervise/pid ] ; do sleep 1 done It would be better if sv(8) itself could synchronise. Earl ----------------------------------------------------------------------- #!/bin/sh rm -rf svc mkdir svc touch svc/down cat > svc/run <<\EOF #!/bin/sh sleep 30 EOF chmod +x svc/run trap 'kill $SVC_' EXIT ../command/runsv ./svc & SVC_=$! ../command/sv once ./svc ../command/sv status ./svc || echo .... Status $? ../command/svwaitup ./svc || echo .... WaitUp $? sleep 2 echo "Try again" ../command/sv status ./svc || echo .... Status $? ../command/svwaitup ./svc || echo .... WaitUp $?