Re: Parallel Booting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 22, 2007 at 05:18:54PM +0200, Harald Hoyer wrote:
> Hello,
> 
> some of you may have read some wiki pages about the plans for the new init system [1]. As a first step in
> this direction [2], I packaged prcsys from Mandriva, patched initscripts with a very small patch, and uploaded
> the src.rpm to [3]. To enable parallel booting just build and install both packages and edit 
> /etc/sysconfig/init. Set PARALLEL_STARTUP=yes and there we go.
> 
> The next step would be to modify all initscripts in /etc/init.d to be LSB compliant [4]. This will speed up
> booting, because they can and will be started in parallel. You should file bugzillas against the component, to 
> which this initscript belongs, with a patch (this has to be done anyway to be LSB compliant in regards to 
> initscripts over time). Especially the exit codes need to be fixed (which will make status queries a lot 
> easier and more robust).
> 
> Early login [5] is also a next step towards a "fast boot" user experience.
> 
> Alternatives to SysVInit (like upstart/initng) can live in Fedora as well, but we are very conservative in
> changing the startup mechanism that proved to function for a long time now. Unless the "real" killer feature
> is absolutly needed, we would like to keep backwards compatibility as long as possible.
> 
> I hope many of you try and test [3] and write patches to improve our service initscripts to be LSB compliant
> :-) Parallel booting is the reward.
> 
> Happy testing,
> Harald
> 
> [1] http://fedoraproject.org/wiki/FCNewInit
> [2] http://fedoraproject.org/wiki/FCNewInit/RC
> [3] http://people.redhat.com/harald/downloads/initscripts/parallel/
> [4] http://fedoraproject.org/wiki/FCNewInit/Initscripts
> [5] http://fedoraproject.org/wiki/FCNewInit/xdm
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 3623 bytes
> Desc: S/MIME Cryptographic Signature
> Url : https://www.redhat.com/archives/fedora-devel-list/attachments/20070622/1a38ff1b/smime.bin
> 
> ------------------------------
> 

Is it something like the script attached? If so then that'll be a really
great idea.

#-----------------------------------------------------------------------

#/bin/bash
# NAME: forfastboot
# PLACE: /root/bin/
# AUTHOR: vikram goyal <vikigoyal@xxxxxxxxx> 230407
#
# The file is to be called as:
# The first time call is the filename itself and then its through service call
#
# service staggered start
#
# So that these services load up in the background & save boot time
#

[ -z "$STLOG" ] && STLOG=/dev/tty
# DEBUGGING
#echo \$1=$1 >> $STLOG
SERVICEDIR=/etc/init.d
SERVICENAME=staggered

addchkserv()
{
# ADD/CHK THE SERVICE
# ~~~~~~~~~~~~~~~~~~~
# If service file has changed copy the new one. If it does not
# exist yet make a new one.
if [ -f $SERVICEDIR/$SERVICENAME ]; then
    fchk=`mktemp`
    createserv $fchk
    [ -n "`diff $fchk $SERVICEDIR/$SERVICENAME`" ] && \
    /sbin/chkconfig --del staggered && \
    mv -f $fchk $SERVICEDIR/$SERVICENAME
    setperms   
else
    createserv $SERVICEDIR/$SERVICENAME
    echo service staggered added.
    setperms
fi
}

addlogrotate()
{
if [ ! -f /etc/logrotate.d/$SERVICENAME ]; then
eval cat >/etc/logrotate.d/$SERVICENAME <<EOF
/var/log/$SERVICENAME.log {
    weekly
    notifempty
    missingok
}
EOF
fi
}

addservnames()
{
# Add the sample file staggered services names list in /etc/sysconfig
servicesnames=`cat /etc/init.d/staggered|grep servicesnames=|cut -d = -f2`
if [ ! -f $servicesnames ]; then
eval cat >$servicesnames <<EOF
#
# Services to be staggered by STAGGERETIME in seconds.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
STAGGERTIME=7

#
# The services mentioned here should be in the right priority
# as mentioned in chkconfig.
#
# This is the list of services which one may want to stagger now
# or in future. So include any service which you want staggered.
#
# In general no service should be here below around 25 start priority
#
STAGGERED_SERVICES=' 26: lm_sensors 55: cups 58: ntpd 60: apcupsd 61: clamav 65: dovecot 80: sendmail spamassassin 88: nasd 95: jexec 98: avahi-daemon wine 99: smartd '

#
# This is the services list which tells staggerd to stay away.
#
# 1} Service may not be in use at the moment.
# 2} Temporarily you may want it out of staggerd.
#
# NOTE: One must switch on the service if it was staggered but
#       has been excluded and you want to use it.
#
EXCLUDE=' lm_sensors cups apcupsd dovecot sendmail spamassassin nasd jexec avahi-daemon wine smartd '
EOF
echo $servicesnames was created. >> $STLOG
fi
}

setperms()
{
    /bin/chmod +x $SERVICEDIR/$SERVICENAME
    /sbin/chkconfig staggered on
}

createserv()
{
# Create service file in /etc/init.d/
eval cat >$1 <<EOF
#!/bin/sh
#
# chkconfig:    2345 99 2
# description:  This is modification of boot process. It staggeres \\
#               the boot services mentioned in /etc/sysconfig/staggered

# Source function library.
. /etc/rc.d/init.d/functions

[ -f /etc/sysconfig/staggered ] && \
export servicesnames=/etc/sysconfig/staggered
name='staggered'
exec='/root/bin/forfastboot'
lockfile="/var/lock/subsys/\$name"
export STLOG=/var/log/staggered.log

RETVAL=0

start() {
    echo -n \$"Starting service staggered: "
    #if [ -f \$lockfile ]; then
    #    echo_failure
    #    echo
    #    return
    #fi
    \$exec servicecall & > /dev/null 2>&1
    #touch \$lockfile
    echo_success && echo
}

stop() {
    echo -n \$"Stopping service staggered: "
    #rm -f \$lockfile
    echo_success && echo
}

case "\$1" in
    start|stop)
        \$1
    ;;
    restart)
        stop
        start
    ;;
    *)
        echo $"Usage: \$0 {start|stop|restart}"
        exit 1
    ;;
esac

exit \$RETVAL
EOF
}

START ()
{
    FN="$1"
    R=`/sbin/runlevel|cut -d ' ' -f2`
    echo -e "\n\t`date`\nSTART:" >> $STLOG
    # DEBUGGING
    #echo \$R=$R >> $STLOG
    for x in $STAGGERED_SERVICES
    do
        [ -n "`echo $x|egrep [0-9]\{1,2\}:?$`" ] && continue
        echo >> $STLOG
        [ ! -f $SERVICEDIR/$x ] && echo "error: file $SERVICEDIR/$x not found" >> $STLOG && continue 
        [ -n "$EXCLUDE" ] && \
        [ -n "`echo $EXCLUDE|grep -w $x`" ] && echo "service $x in exclude list" >> $STLOG && continue
        # Switch off the service. We will manage it ourselves.
        /sbin/chkconfig $x off >> $STLOG 2>&1 &

        unset C
        C=`cat $SERVICEDIR/$x|grep chkconfig|tr '[ ]' '[:]'|tr -s '[:]'|cut -d ":" -f3|grep [\-$R]`

        # DEBUGGING
        #echo \$C=$C \$R=$R >> $STLOG

        # Since the service x has been turned off. Check if it is supposed
        # to run in this level. If yes start it.
        if [ -n "$C" ]; then
            if [ -n "`echo $C|grep \-`" -a -z "`echo $R|grep [2345]`" ]; then
                echo "$R not one of 2,3,4,5 :$x not started" >> $STLOG
		continue
            fi
            /sbin/service $x status >> $STLOG 2>&1 && continue
            [ $? -gt 0 ] && \
            ( /sbin/service $x start >> $STLOG & 2>&1; sleep ${STAGGERTIME}s )
        else
            echo "error: $x not to start in $R" >> $STLOG
        fi
    done
    rm -f "/tmp/$FN"
    echo -e "\n\t`date`\nEND:" >> $STLOG
}

if [ -n "$servicesnames" ]; then
    . $servicesnames
else
    # Not called from service file. It may not exist yet.
    addchkserv
    addservnames
    addlogrotate
fi

if [ -f "$1" ]; then
    # Tmp lock file has been created, so call the function.
    [ -z "$STAGGERTIME" ] && STAGGERTIME=7
    # DEBUGGING
    #echo "loop \$1=$1 exe" >> $STLOG
    START $1
    exit 0
elif [ "$1" != servicecall ]; then
    echo "call $0 from service staggered."
    exit 1
fi

LF=`mktemp`
touch "$LF" || exit 1
$0 "$LF" &
exit

#-----------------------------------------------------------------------
-- 
vikram...
         ||||||||
         ||||||||
^^'''''^^||root||^^^'''''''^^
        // \\   ))
       //(( \\// \\
      // /\\ ||   \\
     || / )) ((    \\
-- 
My own business always bores me to death; I prefer other people's.
		-- Oscar Wilde
-- 
~|~
 =
Registered Linux User #285795

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux