Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Is there a proper way to add pause during rc execution?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
SoLoR
n00b
n00b


Joined: 22 Sep 2004
Posts: 26

PostPosted: Mon Dec 17, 2018 8:32 am    Post subject: Is there a proper way to add pause during rc execution? Reply with quote

Hello,

I was wondering if there is a proper way to add pause during services execution with openrc? I needed to create pause after net interfaces got up, because next service that started was named and sometimes didnt register that network is up and caused problems with resolving because of dnssec and/or couldnt contact root servers during startup, until i restarted named after boot was completed... What i did was create custom init script that runs after net and before named with sleep 3. However is there a proper way to do this? I went thru rc.conf and didnt find anything useful....

Thanks
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30917
Location: here

PostPosted: Mon Dec 17, 2018 8:50 am    Post subject: Reply with quote

If you use dhcp as network manager see https://forums.gentoo.org/viewtopic-t-1088300-highlight-.html
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
SoLoR
n00b
n00b


Joined: 22 Sep 2004
Posts: 26

PostPosted: Mon Dec 17, 2018 12:02 pm    Post subject: Reply with quote

fedeliallalinea wrote:
If you use dhcp as network manager see https://forums.gentoo.org/viewtopic-t-1088300-highlight-.html


i dont, i use static ips and dhcp as a server that gets executed later in the chain. literally named is 1st thing that starts after eth0,1,2 go up. Might help if i moved them in to boot, but i think it wouldnt help much, only thing executed between boot and net interfaces are iptables and it would still be to fast :) but i did see a suggestion in that post to run ntp-client with increased timeout... might try that instead.
Back to top
View user's profile Send private message
ct85711
Veteran
Veteran


Joined: 27 Sep 2005
Posts: 1791

PostPosted: Mon Dec 17, 2018 5:55 pm    Post subject: Reply with quote

Something to look into, is possible look at your /etc/rc.conf. I recall in that file, you could specify if a service needs something or starts before/after something else. This may allow you to get the service to start later in the chain.
Back to top
View user's profile Send private message
SoLoR
n00b
n00b


Joined: 22 Sep 2004
Posts: 26

PostPosted: Mon Dec 17, 2018 6:17 pm    Post subject: Reply with quote

ct85711 wrote:
Something to look into, is possible look at your /etc/rc.conf. I recall in that file, you could specify if a service needs something or starts before/after something else. This may allow you to get the service to start later in the chain.


yes you can use rc_use, rc_after. rc_before, rc_neet etc, even per config base for example inside config in /etc/conf.d, however this doesnt help me, named needs to start early in chain since other services kinda want resolving asap and obviously net interfaces needs to start even earlier :) i find out i kinda need ~3-4sec after interfaces comes up that internet is available, so currently i put net-client to start after interfaces with 4sec delay :) its actually win win, it does pause and sets correct time early in the chain, even tho im starting ntpd later on :P
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Mon Dec 17, 2018 10:06 pm    Post subject: Re: Is there a proper way to add pause during rc execution? Reply with quote

SoLoR wrote:
I needed to create pause after net interfaces got up, because next service that started was named and sometimes didnt register that network is up a....

If you have three interfaces you may have to wait for all three or at least the one that named wants. I ran into that problem with two interfaces. Having just one up satisfied "net" but a following service might need the other interface.

The system seems to assume that their is only one net.X

I also seem to remember that some Intel NIC's needed a pause before they were really up. But I don't remember the details.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Tue Dec 18, 2018 2:09 am    Post subject: Re: Is there a proper way to add pause during rc execution? Reply with quote

SoLoR wrote:
I was wondering if there is a proper way to add pause during services execution with openrc?
There is no proper way to add a pause, because sleeping is never the answer. You cannot guarantee that any particular sleep delay will always be sufficient. You must wait for the requirements to be satisfied. Once you are set up to recognize the requirements are satisfied, you should make the next step be triggered by that detection, rather than by polling.
Back to top
View user's profile Send private message
Muso
Veteran
Veteran


Joined: 22 Oct 2002
Posts: 1052
Location: The Holy city of Honolulu

PostPosted: Tue Dec 18, 2018 7:16 am    Post subject: Reply with quote

I have a rather strange set up on a laptop I use for work. The default wifi chip blows in Linux, so I use an external USB dongle wifi device. Because of this, I do not include the networking protocols during boot, I deal with it after I log in.

Being that wlan1 & wlan0 seem to switch for no reason at all, I am forced to check this myself. My point being, it is not difficult to do things via cli.
_________________
"You can lead a horticulture but you can't make her think" ~ Dorothy Parker
2021 is the year of the Linux Desktop!
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Tue Dec 18, 2018 11:20 am    Post subject: Re: Is there a proper way to add pause during rc execution? Reply with quote

Hu wrote:
There is no proper way to add a pause, because sleeping is never the answer. You cannot guarantee that any particular sleep delay will always be sufficient. You must wait for the requirements to be satisfied. Once you are set up to recognize the requirements are satisfied, you should make the next step be triggered by that detection, rather than by polling.

Pure Gold.
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Tue Dec 18, 2018 11:26 am    Post subject: Reply with quote

Muso wrote:
I have a rather strange set up on a laptop I use for work. The default wifi chip blows in Linux, so I use an external USB dongle wifi device. Because of this, I do not include the networking protocols during boot, I deal with it after I log in.

Being that wlan1 & wlan0 seem to switch for no reason at all, I am forced to check this myself. My point being, it is not difficult to do things via cli.

Off-topic, but the answer for you is to use udev or eudev to solve the kernel race condition. Find a characteristic difference between wlan0 and wlan1 (see udev documentation) and write rules assigning a unique name to each. The kernel assigns wlan0 and wlan1 in the order it sees them. Pick any random name, like Wlan0, Wlan1, eifi0/1, wonboard0, wdongle1, .... Assign a rule based on manufacturer or serial number, bus type (pci/usb) whatever. See the udev docs.
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Tue Dec 18, 2018 12:23 pm    Post subject: Reply with quote

Conceptually it is always better to be event-based not time based.

Introducing a sleep puts you in a position of waiting too long if what was holding you up goes live quicker, OR even worse... your arbitrarily chosen time isn't long enough (for all cases) causing the same problem. Event driven, with a reasonable timeout is usually a more robust method.

Take the problem stated here, this appears to be similar to my problem. Aspects of net.eno1(in my case) are up, but not enough for say ntp-client or netmount to function.

There is a service provided by openRC called net-online that in theory should help. It checks that there is an IP address assigned to an interface as a sign that it is live

By then adding a simple line to the associated /etc/conf.d/* files, an event can be used to hold off starting other services that really require a live network

rc_need="net.eno1 net-online local"

_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum