You are not logged in.

#1 2009-10-09 03:26:44

gabscic
Member
Registered: 2008-11-15
Posts: 19

Can I put an order on background-loaded daemons?

Hello friends, I have found myself in quite a doubt here. Here's the thing:

As you may know, by prefixing an "at" symbol (@) in front of a particular daemon in the daemons section in 'rc.conf' you background its execution, that is, the following daemons will not wait for the backgrounded daemon to successfully start up. However, this may break some scripts if they need a backgrounded daemon. Thus, consider I have the following hypothetical daemons array in rc.conf:

DAEMONS=(.. a b ...)

where '..' is a list of daemons loaded before daemons 'a' and 'b', '...' is a list of daemons loaded after daemons 'a' and 'b' and not dependent on them, 'a' is a hypothetical daemon needed only for a particular activity user-triggered after the machine is all loaded up and 'b' is a hypothetical daemon that needs 'a' for its successful execution. Also, consider that the list '..' takes 2 seconds to load, 'a' takes 15 seconds, and 'b' together with the '...' list takes 1 second to load up. Thus, I would have to wait 18 secs for my linux environment to load up. However if I could background 'a' and 'b' and make 'b' load only after 'a' is loaded, I could boost my load time to about 3 secs. I know the daemons list would still take 18 secs to load up, but the longest daemons would be loading while I'm logging in and all, and I would already have my linux environment available to me. All I would have to do is wait for the 'a' loading to complete so I could start my user-triggered activity, but meanwhile I could already have the whole other environment available. So, my question is: is there a way to background 'a' and 'b' but telling the system to load 'b' only after 'a' is successfully loaded?

For example, if netfs is dependent on the network daemon (is it?) can I make DAEMONS=(.. @network @netfs ...) and tell the system to load netfs only after network?

Sorry for the long post and thanks for all the attention...

PS: by the way, I do not know if all I stated about the daemons and my hypothetical situation is really correct. If not, please correct me. Thanks...

Offline

#2 2009-10-09 03:31:52

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: Can I put an order on background-loaded daemons?

In the absence of real professional advise, might I suggest you look at loading your daemon by adding:-

/etc/rc.d/b start

in /etc/rc.local? This file gets run once everything has started up on your daemon's list.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2009-10-09 05:53:44

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Can I put an order on background-loaded daemons?

There is no way to do what you want within the existing init scripts. As an alternative, you could write a "meta-daemon" which starts/stops a and b in the right order, and background that one in rc.conf.

Offline

#4 2009-10-09 06:15:39

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: Can I put an order on background-loaded daemons?

tomk wrote:

There is no way to do what you want within the existing init scripts. As an alternative, you could write a "meta-daemon" which starts/stops a and b in the right order, and background that one in rc.conf.

Save this code below as /etc/rc.d/ab and then start the 'ab' daemon as a backgrounded daemon.

#!/bin/bash

case "$1" in
  start)
    /etc/rc.d/a start
    /etc/rc.d/b start
    ;;
  stop)
    /etc/rc.d/b stop
    /etc/rc.d/a stop
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0

Assuming that b has to stop before a. If the stopping order doesn't matter then just:

#!/bin/bash

/etc/rc.d/a $1
/etc/rc.d/b $1

exit 0

Last edited by fukawi2 (2009-10-09 06:17:54)

Offline

Board footer

Powered by FluxBB