[Asterisk-Users] starting asterisk with nice -5

Joseph syscon at interbaun.com
Fri Aug 5 17:30:30 MST 2005


Is there any script guru on the list that can help me.
I'm trying to start asterisk with nice -5.
Normally the command would be:
nice -5 asterisk  

but asterisk start from the scrip on Gentoo as -U asterisk -G asterisk
Here is the script:
===============
depend() {
        need net
        use zaptel
}

start() {
        local OPTS USER GROUP

        if [[ -n "${ASTERISK_NICE}" ]]; then
                if [[ ${ASTERISK_NICE} -ge -20 ]] && \
                   [[ ${ASTERISK_NICE} -le  19 ]]; then
                        OPTS="--nicelevel ${ASTERISK_NICE}"
                else
                        eerror "Nice value must be between -20 and 19"
                fi
        fi

        if [[ -n "${ASTERISK_USER}" ]]; then
                USER=${ASTERISK_USER/:*/}
                GROUP=$(echo $ASTERISK_USER | awk -F: '/.*:.*/ { print
$2 }')
                if [[ -n "${USER}" ]]; then
                        ASTERISK_OPTS="${ASTERISK_OPTS} -U ${USER}"
                fi
                if [[ -n "${GROUP}" ]]; then
                        ASTERISK_OPTS="${ASTERISK_OPTS} -G ${GROUP}"
                        GROUP=":${GROUP}"       # make it look nice...
                fi
                ebegin "Starting asterisk PBX (as ${USER}${GROUP})"
        else
                ebegin "Starting asterisk PBX (as root)"
        fi
                start-stop-daemon --start --exec /usr/sbin/asterisk \
                        ${OPTS} -- ${ASTERISK_OPTS}
        eend $?
}

stop() {
        ebegin "Stopping asterisk PBX"
        start-stop-daemon --stop
--pidfile /var/run/asterisk/asterisk.pid
        eend $?
}
======================

I was under impression that modifying the line:
start-stop-daemon --start --exec /usr/sbin/asterisk \

to:
start-stop-daemon --start --exec /usr/bin/nice -n -5 /usr/sbin/asterisk \

would to the trick but it doesn't.  If I do that asterisk runs at "nice
10" and that wasn't my intension.
How to start it at nice -5?

With default asterisk run at the same nice level "0" as apache and when
a fax comes in sometimes I get a lot of bad lines.
So, adjusting nice level to -5 for asterisk might help I would think.
Asterisk intercept faxes and forwards it to hylafax fax extension.

-- 
#Joseph



More information about the asterisk-users mailing list