supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* pownernowd run script
@ 2006-07-03  8:32 xavier dutoit
  2006-07-04 14:46 ` Gerrit Pape
  0 siblings, 1 reply; 2+ messages in thread
From: xavier dutoit @ 2006-07-03  8:32 UTC (permalink / raw)


Hello,

I've written a run script for powernowd (tested on a sarge with
standard package):

#! /bin/sh
modprobe cpufreq-userspace
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]
  then
    exec /usr/sbin/powernowd -d
  else
    echo "required sysfs objects not found!"
    echo -e "\tRead /usr/share/doc/powernowd/README.Debian for more
information."
fi


I wasn't sure about how to deal with error messages if the proc can't
change its frequency. I kept what the init.d script did.

I hope it might be useful to someone, and forgive me if the code
doesn't do it the runit way, that's my first run script.

Any suggestion to improve more than welcome.


Xavier


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: pownernowd run script
  2006-07-03  8:32 pownernowd run script xavier dutoit
@ 2006-07-04 14:46 ` Gerrit Pape
  0 siblings, 0 replies; 2+ messages in thread
From: Gerrit Pape @ 2006-07-04 14:46 UTC (permalink / raw)


On Mon, Jul 03, 2006 at 10:32:26AM +0200, xavier dutoit wrote:
> I've written a run script for powernowd (tested on a sarge with
> standard package):
> 
> #! /bin/sh
> modprobe cpufreq-userspace
> if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]
>  then
>    exec /usr/sbin/powernowd -d
>  else
>    echo "required sysfs objects not found!"
>    echo -e "\tRead /usr/share/doc/powernowd/README.Debian for more
> information."
> fi
> 
> 
> I wasn't sure about how to deal with error messages if the proc can't
> change its frequency. I kept what the init.d script did.

If the scaling_governor file does not exist, runit will retry to start
the service every second.  That's good for temporary errors but not for
permanent ones.  I'm not sure whether this one is temporary.
Additionally modprobe might fail, so, if the absence of scaling_governor
is a permanent error, I'd suggest:

  #!/bin/sh
  set -e  # barf if modprobe fails
  modprobe cpufreq-userspace
  test ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ||
    exec /usr/sbin/powernowd -d

  echo "required sysfs objects not found!"
  echo "Read /usr/share/doc/powernowd/README.Debian for more information."
  sv down "$(pwd)"

And note where the echo output goes to.  If this service has a log
service, the warning goes to the log, if not, it goes to the console.
If you redirect the echo output to stderr, the warning would end up in
the readproctitle log.

HTH, Gerrit.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-04 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-03  8:32 pownernowd run script xavier dutoit
2006-07-04 14:46 ` Gerrit Pape

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).