[ Content | View menu ]

Fiddling with the daemons

I noticed one thing that was slowing down my entire boot process - daemons. I currently start all of my daemons in the background, except for syslog-ng, ptal-init and occasionally dhcdbd. This is, of course, irritating to someone like me who wants to boot at as fast a speed as possible. It took a bit of brainstorming, but I came up with a solution!

Firstly, I organised my daemons into three arrays in rc.conf, DAEMONSHIGH for high-priority daemons, DAEMONSMID for mid-priority daemons, and DAEMONSLOW for low-priority daemons. This is what I ended up with

DAEMONSHIGH=(syslog-ng)
DAEMONSMID=(network alsa hal fam)
DAEMONSLOW=(!dhcdbd !networkmanager ptal-init cups)

As you can see, none of those daemons have an @ in front - so you’d think none of them would be backgrounded, right? Wrong! My next step was to edit rc.multi, where the actual loading of the daemons happens. I made all daemons in DAEMONSHIGH start in the forground, all daemons in DAEMONSMID start in the background, and all daemons in DAEMONSLOW to start in a background loop. This ensures that the daemons in DAEMONSLOW start in the correct order, but without slowing boot at all.

I ended up with this code, notice that the code for loading DAEMONSLOW is after executing rc.local:

# Start high-priority daemons
for daemon in “${DAEMONSHIGH}”; do
if [ "$daemon" = "${daemon#!}" ]; then
export DAEMONSTATE=NORM
(/etc/rc.d/${daemon:1} start) &>/dev/null
fi
done

# Start mid-priority daemons
for daemon in “${DAEMONSMID}”; do
if [ "$daemon" = "${daemon#!}" ]; then
export DAEMONSTATE=BKGD
stat_bkgd “Starting ${daemon:1}”
(/etc/rc.d/${daemon:1} start) &a,mp;>/dev/null &
splash_check && /sbin/${SPLASH}_wrapper multi_progress
fi
done

if [ -x /etc/rc.local ]; then
/etc/rc.local
fi

# Start low-priority daemons
( for daemon in “${DAEMONSLOW}”; do
if [ "$daemon" = "${daemon#!}" ]; then
export DAEMONSTATE=NORM
(/etc/rc.d/${daemon:1} start) &>/dev/null
fi
done ) &

I have yet to test it, I’m currently converting a few thousand mp3 files to ogg vorbus, but I will do so as soon as possible.

Filed in Linux, under , , , on May 27, 2008

No Comments

Write comment - TrackBack - RSS Comments

Write comment