From: Alex Efros <powerman@powerman.asdfGroup.com>
Subject: Re: Option for runsv/runsvdir to specify how many times to restart a service in a certain time period before giving up?
Date: Mon, 30 Oct 2006 16:24:20 +0200 [thread overview]
Message-ID: <20061030142420.GC23323@home.power> (raw)
In-Reply-To: <20061030135834.GA26907@skarnet.org>
Hi!
On Mon, Oct 30, 2006 at 02:58:34PM +0100, Laurent Bercot wrote:
> Another approach to the throttle feature that doesn't require notification
> from runit would be to have a short-lived program, designed to be called in
> the finish script, that stores its information (last calling time ans such)
> in the filesystem. Maybe it's what you were thinking about. But I'm not
Yep, I'm thinking this way.
> sure how to make it reliable; storing short-lived information in the
> filesystem is very error-prone, that's the .pid way, which is precisely
> what supervision tools were designed to avoid.
I don't see any troubles making it reliable. DJB show how to develop
reliable shell scripts long time ago: use atomic operations like 'mv'
for updating files.
# reliable counter in bash
prev=$(< .counter )
next=$(( $prev + 1 ))
echo $next > .counter.$$
mv .counter.$$ .counter
For this task we need something more complex than just counter because we
should count restarts for some time interval, but this also can be done in
reliable way.
P.S. If my script die before `mv` it can leave .counter.$$ file on disk.
If this important we can add cleanup code. If it's important to not run 2
such scripts simultaneously, then we can use something like `chpst -l`.
Etc... Reliable shell scripts is reality, let's face it. ;-)
--
WBR, Alex.
next prev parent reply other threads:[~2006-10-30 14:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-28 19:26 Alex Smith
2006-10-30 10:49 ` Alex Efros
2006-10-30 10:50 ` Alex Efros
2006-10-30 12:13 ` Dražen Kačar
2006-10-30 12:30 ` Alex Efros
2006-10-30 13:38 ` Laurent Bercot
2006-10-30 13:42 ` Alex Efros
2006-10-30 13:58 ` Laurent Bercot
2006-10-30 14:24 ` Alex Efros [this message]
2006-10-30 14:51 ` Charlie Brady
2006-10-31 0:48 ` Laurent Bercot
2006-10-30 18:49 ` Vincent Danen
2006-10-30 21:28 ` Alex Efros
2006-10-30 21:30 ` Vincent Danen
2006-10-30 17:52 ` Alex Smith
2006-10-30 21:41 ` Alex Efros
2006-11-01 12:01 ` Gerrit Pape
2006-11-01 12:17 ` Alex Efros
2006-10-30 18:49 ` Dražen Kačar
2006-10-30 22:03 ` Alex Efros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061030142420.GC23323@home.power \
--to=powerman@powerman.asdfgroup.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).