Index: example.service_mk ================================================================== --- example.service_mk +++ example.service_mk @@ -18,20 +18,27 @@ # flags to prevent daemonizing DAEMON_example_FOREGROUND?= # group to run service as DAEMON_example_GROUP?=wheel + +# lower process priority by using `idprio` +DAEMON_example_IDPRIO?= # kernel modules to load prior to service start DAEMON_example_MODULES?= + +# raise process priority by using `rtprio` +# (IDPRIO setting takes precedence if set) +DAEMON_example_RTPRIO?= # user to run service as DAEMON_example_USER?=root # extra commands to execute before starting service -# ${_SERVICE} - starts after root mount appear -# ${_EARLYSERVICE} - not required on early boot +# ${_EARLYSERVICE} - starts after root mount appear +# ${_SERVICE} - not required on early boot # you also can select specific starter by inheriting class by full name: # ${_(EARLY)?SERVICE(_(SVC|DAEMON|PLAIN))?} example: ${_EARLYSERVICE} : run commands that should go before the service start Index: starter.mk ================================================================== --- starter.mk +++ starter.mk @@ -4,18 +4,29 @@ _service_check: .USEBEFORE # check whether service is enabled if [ -z "$${DAEMON_$@_ENABLE}" -a -z "${FORCE}" ]; then \ exit 0 ;\ - fi ;\ - for CMD in ${DAEMON_$@_COMMAND}; do \ - if [ -x $${CMD} ]; then \ - export CMD ;\ + fi + # check for first present executable + for COMMAND in ${DAEMON_$@_COMMAND}; do \ + if [ -x $${COMMAND} ]; then \ + export CMD="${COMMAND}" ;\ break ;\ fi ;\ - done ;\ - echo $${CMD} + done + # bail out if binary not found + if [ -z $${CMD} ]; then \ + MRC:$@> Executable not found. + exit 0 ;\ + fi + # check for rtprio/idprio + if [ -n "$${DAEMON_$@_IDPRIO}" ]; then \ + export CMD="/usr/sbin/idprio $${DAEMON_$@_IDPRIO} $${CMD}" ;\ + elif [ -n "$${DAEMON_$@_RTPRIO}" ]; then \ + export CMD="/usr/sbin/rtprio $${DAEMON_$@_RTPRIO} $${CMD}" ;\ + fi _service_pre: .USEBEFORE # kldload modules if any echo "MRC:$@> Starting service." ;\ if [ -n "${DAEMON_$@_MODULES}" ]; then \