On Tue, Sep 04, 2018 at 04:58:53AM +0200, Thomas de Grivel wrote:
> Thanks, good to know.
> 
> But if I actually wanted per daemon priorities with settable
> configuration in rc.conf.local how would I get that ? And I still feel

You would do what the man page instructs you to do in login.conf:

mydaemon1:\
        :priority=10:\
        :tc=daemon:

mydaemon2:\
        :priority=5:\
        :tc=daemon:

etc.

Where mydaemon1 and mydaemon2 each matches an rc.d script name under /etc/rc.d/

> the default nice priority of 10 is rather a good idea.

I disagree.


> Le lun. 3 sept. 2018 à 23:10, Antoine Jacoutot <ajacou...@openbsd.org> a 
> écrit :
> >
> > On Mon, Sep 03, 2018 at 10:34:51PM +0200, Thomas de Grivel wrote:
> > > Hello,
> >
> > Hi.
> >
> > > Following patch allows sysadmins to configure nice values for RC daemons.
> > > Default nice value is set to 10 as I wish to prioritize interactive
> > > applications over system daemons and I think most probably do too.
> > > It is based on OpenBSD 6.3 but might apply easily to later releases.
> > > Please let me know if it is of any interest to you.
> >
> > We already support that.
> >
> > Extract from rc.d(8):
> >
> >      daemon_class is a special read-only variable.  It is set to “daemon”
> >      unless there is a login class configured in login.conf(5) with the same
> >      name as the rc.d script itself, in which case it will be set to that
> >      login class.  This allows setting many initial process properties, for
> >      example environment variables, scheduling priority, and process limits
> >      such as maximum memory use and number of files.
> >
> > Extract from login.conf(5):
> >
> >      priority           number                   Initial priority (nice)
> >                                                  level.
> >
> > Cheers!
> >
> >
> > > commit 1f4121df3ae31121d435571ffdbd93a20c1e8a07
> > > Author: Thomas de Grivel <tho...@gmail.com>
> > > Date:   Mon Sep 3 21:52:37 2018 +0200
> > >
> > >     Add a $daemon_nice parameter.
> > >     If not overriden by the launched daemon the default nice value is 10.
> > >     See nice(1) for more details.
> > >
> > > diff --git rc.d/rc.subr.orig rc.d/rc.subr
> > > index 6c2f694..5f4fbe5 100644
> > > --- rc.d/rc.subr.orig
> > > +++ rc.d/rc.subr
> > > @@ -49,6 +49,7 @@ _rc_write_runfile() {
> > >   cat >${_RC_RUNFILE} <<EOF
> > >  daemon_class=${daemon_class}
> > >  daemon_flags=${daemon_flags}
> > > +daemon_nice=${daemon_nice}
> > >  daemon_rtable=${daemon_rtable}
> > >  daemon_timeout=${daemon_timeout}
> > >  daemon_user=${daemon_user}
> > > @@ -170,7 +171,7 @@ _rc_parse_conf() {
> > >  [ -n "${FUNCS_ONLY}" ] && return
> > >
> > >  rc_start() {
> > > - ${rcexec} "${daemon} ${daemon_flags}"
> > > + ${rcexec} "nice -n ${daemon_nice} ${daemon} ${daemon_flags}"
> > >  }
> > >
> > >  rc_check() {
> > > @@ -288,6 +289,7 @@ _RC_RUNFILE=${_RC_RUNDIR}/${_name}
> > >  _rc_do _rc_parse_conf
> > >
> > >  eval _rcflags=\${${_name}_flags}
> > > +eval _rcnice=\${${_name}_nice}
> > >  eval _rcrtable=\${${_name}_rtable}
> > >  eval _rcuser=\${${_name}_user}
> > >  eval _rctimeout=\${${_name}_timeout}
> > > @@ -295,6 +297,7 @@ eval _rctimeout=\${${_name}_timeout}
> > >  # set default values; duplicated in rcctl(8)
> > >  getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && 
> > > daemon_class=${_name} ||
> > >   daemon_class=daemon
> > > +[ -z "${daemon_nice}" ] && daemon_nice=10
> > >  [ -z "${daemon_rtable}" ] && daemon_rtable=0
> > >  [ -z "${daemon_user}" ] && daemon_user=root
> > >  [ -z "${daemon_timeout}" ] && daemon_timeout=30
> > > @@ -304,6 +307,7 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null
> > > 2>&1 && daemon_class=${_name} ||
> > >   unset _rcflags
> > >
> > >  [ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
> > > +[ -n "${_rcnice}" ] && daemon_nice=${_rcnice}
> > >  [ -n "${_rcrtable}" ] && daemon_rtable=${_rcrtable}
> > >  [ -n "${_rcuser}" ] && daemon_user=${_rcuser}
> > >  [ -n "${_rctimeout}" ] && daemon_timeout=${_rctimeout}
> > > @@ -315,7 +319,7 @@ if [ -n "${_RC_DEBUG}" ]; then
> > >  fi
> > >
> > >  readonly daemon_class
> > > -unset _rcflags _rcrtable _rcuser _rctimeout
> > > +unset _rcflags _rcnice _rcrtable _rcuser _rctimeout
> > >  pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
> > >  rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
> > >  [ "${daemon_rtable}" -eq 0 ] ||
> > >
> > >
> > > --
> > >  Thomas de Grivel
> > >
> >
> > --
> > Antoine
> 
> 
> 
> -- 
>  Thomas de Grivel
>  http://b.lowh.net/billitch/
> 

-- 
Antoine

Reply via email to