View previous topic :: View next topic |
Author |
Message |
SoLoR n00b
Joined: 22 Sep 2004 Posts: 26
|
Posted: Mon Dec 17, 2018 8:32 am Post subject: Is there a proper way to add pause during rc execution? |
|
|
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 |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30917 Location: here
|
|
Back to top |
|
|
SoLoR n00b
Joined: 22 Sep 2004 Posts: 26
|
Posted: Mon Dec 17, 2018 12:02 pm Post subject: |
|
|
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 |
|
|
ct85711 Veteran
Joined: 27 Sep 2005 Posts: 1791
|
Posted: Mon Dec 17, 2018 5:55 pm Post subject: |
|
|
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 |
|
|
SoLoR n00b
Joined: 22 Sep 2004 Posts: 26
|
Posted: Mon Dec 17, 2018 6:17 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Mon Dec 17, 2018 10:06 pm Post subject: Re: Is there a proper way to add pause during rc execution? |
|
|
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 |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21635
|
Posted: Tue Dec 18, 2018 2:09 am Post subject: Re: Is there a proper way to add pause during rc execution? |
|
|
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 |
|
|
Muso Veteran
Joined: 22 Oct 2002 Posts: 1052 Location: The Holy city of Honolulu
|
Posted: Tue Dec 18, 2018 7:16 am Post subject: |
|
|
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 |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Tue Dec 18, 2018 11:20 am Post subject: Re: Is there a proper way to add pause during rc execution? |
|
|
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 |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Tue Dec 18, 2018 11:26 am Post subject: |
|
|
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 |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Tue Dec 18, 2018 12:23 pm Post subject: |
|
|
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 |
|
|
|