On 2013-12-21 Sat 17:13 PM |, Alexander Hall wrote:
> >
> >Comments/testing observations/?
> 
> This is not the purpose nor responsibility off the rc.d scripts.
> 
> 

What alternatives have you in mind?

Maybe an /etc/rc.nicetab which a root run cron job parses for daemon
values, then checks that against the process tree. Repeated every
minute... in case some process was started.

Unlikely.

This is cleaner & works:


> >
> >ksh syntax used (which works with /bin/sh & bin/ksh being the same
> >binary), but dinnae ken if that's "wrong"... for rc* stuff.
> >
> >
> >> Use renice as simple nice didn't always work on daemons started in
> >the
> >> background. Niceness level sanity checked, defaulting to 10.
> >> 
> >> Index: rc.subr
> >> ===================================================================
> >> RCS file: /cvs/src/etc/rc.d/rc.subr,v
> >> retrieving revision 1.70
> >> diff -u -u -p -r1.70 rc.subr
> >> --- rc.subr        11 Jul 2013 09:34:33 -0000      1.70
> >> +++ rc.subr        19 Dec 2013 13:17:45 -0000
> >> @@ -104,6 +104,25 @@ rc_wait() {
> >>    return 1
> >>  }
> >>  
> >> +rc_reprioritise()
> >> +{
> >> +  [[ ${rc_renice} != 'YES' ]] &&
> >> +  {
> >> +          for _renice_level in $(jot 40 20 -20)
> >> +          do
> >> +                  [[ ${rc_renice} == ${_renice_level} ]] &&
> >> +                  {
> >> +                          _scheduling_priority=${rc_renice}
> >> +                          break
> >> +                  }
> >> +          done
> >> +  }
> >> +
> >> +  [[ -z ${_scheduling_priority} ]] && _scheduling_priority='10'
> >> +
> >> +  renice -n ${_scheduling_priority} -p $(pgrep -f "^${pexp}")
> >> +}
> >> +
> >>  rc_cmd() {
> >>    local _bg _n
> >>  
> >> @@ -136,6 +155,17 @@ rc_cmd() {
> >>            fi
> >>            [ -z "${INRC}" ] && rc_do rc_check && exit 0
> >>            echo $_n "${INRC:+ }${_name}"
> >> +
> >> +          [[ ${rc_renice} == 'NO' ]] && unset rc_renice
> >> +          [[ -n ${rc_renice} ]] &&
> >> +          {
> >> +                  printf "%d" ${rc_renice} > /dev/null 2>&1 &&
> >> +                  {
> >> +                          rc_renice=$(printf "%d" ${rc_renice})
> >> +                          [[ ${rc_renice} -eq 0 ]] && unset rc_renice
> >> +                  }
> >> +          }
> >> +
> >>            while true; do  # no real loop, only needed to break
> >>                    if type rc_pre >/dev/null; then
> >>                            rc_do rc_pre || break
> >> @@ -148,6 +178,7 @@ rc_cmd() {
> >>                            rc_do rc_wait start || break
> >>                    fi
> >>                    rc_do rc_write_runfile
> >> +                  [[ -n ${rc_renice} ]] && rc_do rc_reprioritise
> >>                    rc_exit ok
> >>            done
> >>            # handle failure
> >> 
> 

-- 
Craig Skinner | http://twitter.com/Craig_Skinner | http://linkd.in/yGqkv7

Reply via email to