You are not logged in.

#1 2007-06-12 13:42:28

George_K
Member
From: Russie, Saint-Pétersbourg
Registered: 2006-09-27
Posts: 75

/etc/rc.conf enhancement: daemons startup

I think that current method of starting daemons is not flexible enough.
For me the problem is that I want to start network with Internet connection and X server at the same time and have as quick boot as possible, but some services depend on network connection, some on Internet connection, there are some other dependencies...
Adding dependencies to ArchLinux daemons was already discussed a couple of times... but I will not talk about adding dependencies anymore ;) because:
1) Most start-up systems are much more complicated and heavy than our. Such a system may run counter to the KISS principle and there are Arch users which are happy with current state of things.
2) Dependencies may not be flexible enough :) . For example, B (internet connection) and C (jabberd, dhcpd, nfs, etc.) depends on A (network), but I don`t wont to start them simultaneously because I want to give one half of my HT or dual core cpu to start D (kdm), E or something other which is more useful for a desktop user.
Not to talk too much, I`ll show, as not-an-absolutely-real-life example, part of /etc/rc.conf:

Dnfs=(netfs nfslock nfsd)
Dnetwork=(network routes portmap openl2tpd @^Dnfs @dhcpd)
DAEMONS=(@^Dnetwork @kdm @mpd)

And this is an example script which is a modified version of /etc/rc.multi (but not a replacement for /etc/rc.multi - it is only for testing):

#!/bin/bash

. /etc/rc.d/functions

Dnfs=(netfs nfslock nfsd)
Dnetwork=(network routes portmap openl2tpd @^Dnfs @dhcpd)
DAEMONS=(@^Dnetwork @xdm sleep)

function rundaemon() {
        daemon=$1
        if [ ! "$daemon" = "${daemon#!}" ]; then
            return
        fi
        if [ ! "$daemon" = "${daemon#^}" ]; then
            eval daemon=\${${daemon:1}[@]}
            rundaemons ${daemon[@]}
            return
        fi
        echo "/etc/rc.d/$daemon start"
        sleep 1 #to let you see the order
}

function rundaemons() {
    while [ "$#" -ne "0" ]; do
        daemon=$1
        if [ ! "$daemon" = "${daemon#@}" ]; then
            eval daemon=${daemon:1}
            stat_bkgd "Starting $daemon"
            #(rundaemon $daemon) &>/dev/null &
            (rundaemon $daemon) & #to ley you see what is going on
        else
            rundaemon $1
        fi
        shift
    done
}

rundaemons ${DAEMONS[@]}
echo "All foregroud daemons already started!"

# vim: ts=2

I not only added new functionality to rc.multi but also redesigned it a little to reduce level of an enclosure of "if" constructions.
I`m not a professional bash programmer so I think it is possible to reduce the size of this script at least by 1.3.

Offline

#2 2007-06-12 15:31:43

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: /etc/rc.conf enhancement: daemons startup

I've never had a problem with backgrounding every daemon I have.  Even if some services "require a network" - they really don't.  I can start ssh, apache, etc without a network connection, when the network connections, they all work fine.

Offline

#3 2007-06-12 15:45:58

hussam
Member
Registered: 2006-03-26
Posts: 572
Website

Re: /etc/rc.conf enhancement: daemons startup

Daemon dependencies is not really "counter to the KISS principle" but it doesn't really matter.

The only exception I know is the adsl daemon which will not start unless networking is up. If networking is not up yet, adsl will fail to start.

Offline

#4 2007-06-12 16:37:28

George_K
Member
From: Russie, Saint-Pétersbourg
Registered: 2006-09-27
Posts: 75

Re: /etc/rc.conf enhancement: daemons startup

phrakture wrote:

Even if some services "require a network" - they really don't.  I can start ssh, apache, etc without a network connection, when the network connections, they all work fine.

Yes, most services work fine and you can simply background them. But some don`t.
For me writing meta-daemons started from portmap->nfslock->nfsd chain. Then was adsl with ez-ipupdate but I combined them in /etc/rc.d/adsl. At that time "network" was not backgrounded so I had not problems with adsl. Some time ago I switched my Internet provider so currently I have access to the Internet via VPN via ethernet. From that time I switched from statical IP address to dhcp assignment :) . The best l2tp client is openl2tp which requires portmap to start. And ez-ipupdate should be started after VPN is up. So you see, I really need more flexible way to start daemons than our current. I see two different methods of solving it: using real dependencies and writing simple dependencies in /etc/rc.conf manually.
Summary about why or what for the method described in the first post is needed:
1) "It is designed to easily solve easy problems" (the user don`t have to change something in rc.conf and the system will work as always), "retaining the possibility to solve harder task" (such as in this example).
2) It allows user to save some seconds of bootup time (time from power-on to login prompt/screen) by moving tasks with lower priority to the end of the task queue.

Last edited by George_K (2007-06-12 16:46:57)

Offline

#5 2007-06-12 21:20:02

hacosta
Member
From: Mexico
Registered: 2006-10-22
Posts: 423

Re: /etc/rc.conf enhancement: daemons startup

i think dependencies are the way to go, besides arch already does this, only that it does it in a non-clean way... take dbus and hal for example


case "$1" in
    start)
        #Check for running dbus, start when not running
        ck_daemon dbus && /etc/rc.d/dbus start
    if [ -x /etc/rc.d/acpid ]; then
        ck_daemon acpid && /etc/rc.d/acpid start
    fi

why not just have DEPENDENCIES=(acpid dbus).. same applies to other packages cups, fam.. i feel most people dislike this idea because they feel /etc/rc.conf's module array will be no more. but in fact it doesn't even need to change, so i think dependencies are both easy enough to implement kiss, and most importantly one would not need to change the current rc.conf format

my 2 pesos

edit: perhaps non-clean is not the word i'm looking for.. but you know, a standarized way to do this accross init-scripts whould be great

Last edited by hacosta (2007-06-12 21:22:18)

Offline

#6 2007-06-13 05:58:34

George_K
Member
From: Russie, Saint-Pétersbourg
Registered: 2006-09-27
Posts: 75

Re: /etc/rc.conf enhancement: daemons startup

hacosta wrote:

why not just have DEPENDENCIES=(acpid dbus).. same applies to other packages cups, fam.. i feel most people dislike this idea because they feel /etc/rc.conf's module array will be no more. but in fact it doesn't even need to change, so i think dependencies are both easy enough to implement kiss, and most importantly one would not need to change the current rc.conf format

This was already discussed: http://bbs.archlinux.org/viewtopic.php?id=31546

easy enough to implement

You are welcome.

2phrakture: I`ll send a working implementation today.

Offline

#7 2007-06-13 12:45:00

George_K
Member
From: Russie, Saint-Pétersbourg
Registered: 2006-09-27
Posts: 75

Re: /etc/rc.conf enhancement: daemons startup

Ok, the patch is here: http://pastebin.archlinux.org/4514 .
Go to /etc, backup rc.multi and rc.shutdown and apply it with command "patch -p1 <PATCHNAME".
This is an extract of my rc.conf:

Dnetwork=(network routes portmap openl2tp dhcpd netfs nfslock nfsd pdnsd)
DAEMONS=(syslog-ng @^Dnetwork @alsa @mpd @timidity++ @hal kdm @gpm @tftpd @jabberd @pyicqt @httpd @cups @crond)

Warning: don`t use ^@groupname.

Last edited by George_K (2007-06-16 06:14:14)

Offline

Board footer

Powered by FluxBB