Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenRC shutdown sequence
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
willem-jan
n00b
n00b


Joined: 12 Sep 2021
Posts: 7

PostPosted: Sun Sep 12, 2021 4:43 pm    Post subject: OpenRC shutdown sequence Reply with quote

Hi All,

I really love OpenRC, especially it's simplicity over systemd. There is however one annoyance that I cannot seem to fix. During each shutdown/restart I get this error (often 2 times):

Code:
Call to flock failed: Resource temporarily unavailable


There is not much that I could find online regarding this error. But after some digging and trial&error on my system I track the issue down to one of the services. More specifically these two services play a role:

- NetworkManager
- Syncthing

Synchting has a 'depend' section in its init.d file:

Code:
depend() {
  need localmount net
}


And since NetworkManager has:

Code:
depend() {
        need dbus
        use consolekit
        provide net
}


Syncthing will wait untill NetworkManager is running. This is a good thing since Syncthing relies on network/internet connectivity. I would expect that when I shutdown the system, syncthing would stop before NetworkManager. This is however not the case.

If I manually shutdown Syncthing before I shutdown the system the 'flock' error is not present.

Question: how can I change the init.d/conf/OpenRC in such a way that Syncthing stops before NetworkManager?

Or in more general wording: how can I change the shutdown sequence of services?



--- edit ---
For completeness a part of the syslog:

Code:
Sep 12 18:28:30 XPS15 shutdown[2650]: shutting down for system reboot
Sep 12 18:28:30 XPS15 init: Switching to runlevel: 6
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8039] device (eth0): state change: activated -> deactivating (reason 'connection-removed', sys-iface-state: 'managed')
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8040] manager: NetworkManager state is now DISCONNECTING
Sep 12 18:28:30 XPS15 dbus-daemon[1412]: [system] Activating service name='org.freedesktop.nm_dispatcher' requested by ':1.1' (uid=0 pid=1761 comm="/usr/sbin/NetworkManager --pid-file /run/NetworkMa" label="kernel") (using servicehelper)
Sep 12 18:28:30 XPS15 dbus-daemon[1412]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Sep 12 18:28:30 XPS15 root: Unmounting NFS shares gracefully before the network goes down...
Sep 12 18:28:30 XPS15 root: Unmounted NFS shares successfully.
Sep 12 18:28:30 XPS15 init: Trying to re-exec init
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8199] device (eth0): state change: deactivating -> disconnected (reason 'connection-removed', sys-iface-state: 'managed')
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8282] dhcp4 (eth0): canceled DHCP transaction
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8283] dhcp4 (eth0): state changed bound -> terminated
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8419] manager: NetworkManager state is now DISCONNECTED
Sep 12 18:28:30 XPS15 NetworkManager[1761]: <info>  [1631464110.8762] device (eth0): state change: disconnected -> unavailable (reason 'carrier-changed', sys-iface-state: 'managed')
Sep 12 18:28:29 XPS15 kernel: r8152 2-1.1:1.0 eth0: carrier off
Sep 12 18:28:31 XPS15 start-stop-daemon: Will stop /usr/bin/vnstatd
Sep 12 18:28:31 XPS15 start-stop-daemon: Will stop PID 2170
Sep 12 18:28:31 XPS15 start-stop-daemon: Sending signal 15 to PID 2170
Sep 12 18:28:31 XPS15 vnstatd[2170]: SIGTERM received, exiting.
Sep 12 18:28:31 XPS15 start-stop-daemon: Will stop /usr/bin/syncthing
Sep 12 18:28:31 XPS15 start-stop-daemon: Will stop PID 2340
Sep 12 18:28:31 XPS15 start-stop-daemon: Sending signal 15 to PID 2340

-->   Sep 12 18:28:31 XPS15 openrc[2676]: Call to flock failed: Resource temporarily unavailable

Sep 12 18:28:31 XPS15 start-stop-daemon: Will stop /usr/sbin/rpc.idmapd
Sep 12 18:28:31 XPS15 start-stop-daemon: Sending signal 15 to PID 2104
Sep 12 18:28:31 XPS15 rpc.idmapd[2104]: exiting on signal 15
Sep 12 18:28:31 XPS15 start-stop-daemon: Will stop /sbin/rpc.statd


As you can see, NetworkManager shutdown is invoked before Syncthing shutdown.
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sun Sep 12, 2021 10:37 pm    Post subject: Reply with quote

There is a good bit of information in /usr/share/doc/openrc-0.43.5/service-script-guide.md.bz2

Your openrc version and compression for docs may vary, but generally check /usr/share/doc/openrc-*/service-script-guide.*

The stop sequence parameters are covered by start parameter "depends" vs. "uses" sort of thing.
Back to top
View user's profile Send private message
willem-jan
n00b
n00b


Joined: 12 Sep 2021
Posts: 7

PostPosted: Mon Sep 13, 2021 7:13 am    Post subject: Reply with quote

Thank you.

I have also found this on the OpenRC Github page. As far as I understood everything seems configured ok. Syncthing is using 'depend need net'. And while this also works correctly when I, for example, stop NetworkManager manually: syncthing is automatically stopped before NetworkManager is stopped. But it does not work when shutting down the system.

I am also not using 'rc_parallel="YES"'. So everything should be stopped sequentially. From the log this indeed seems the case.

The only problem is that is seems that NetworkManager is stopped before syncthing, which it obviously shouldn't. But maybe something else is causing this 'order change'? Or maybe it is even something completely else causing this problem?

Anyone a clue?
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Mon Sep 13, 2021 11:39 am    Post subject: Reply with quote

My guess is the issue is that more than one service in /etc/init.d provides "net."

Is openrc setup to start any /etc/init.d/net.eth0 or other network, in addition to NetworkManager?

I don't run network manager or syncthing, so just stabbing inthe dark here. I did do some "grep need /etc/init.d" and "grep provide /etc/init.d" to get a sense of absolute dependencies.

I see openrc provides a service called "net-online" too. Never played with that one, but maybe just adding that will resolve the issue.
Back to top
View user's profile Send private message
AJM
Apprentice
Apprentice


Joined: 25 Sep 2002
Posts: 189
Location: Aberdeen, Scotland

PostPosted: Mon Sep 13, 2021 8:20 pm    Post subject: Reply with quote

Maybe this is a cheat kind of answer, but could you not just do away with NM? Unless your machine is a laptop which is used in many locations there's very little reason to use NM at all IMO.
Back to top
View user's profile Send private message
Goverp
Veteran
Veteran


Joined: 07 Mar 2007
Posts: 1995

PostPosted: Tue Sep 14, 2021 9:35 am    Post subject: Reply with quote

AJM wrote:
Maybe this is a cheat kind of answer, but could you not just do away with NM? Unless your machine is a laptop which is used in many locations there's very little reason to use NM at all IMO.

+1
I just use wpa_supplicant's gui. Seems perfectly adequate for the case where you have a list of access points each relevant to a different location. Not having NM saves building both it and modem manger. However, AFAIK systemd setups expect it, though they can be configured to work without it.
_________________
Greybeard
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Tue Sep 14, 2021 10:53 am    Post subject: Reply with quote

Heh ... I've been doing wpa_supplicant the hard way for years. Didn't even know there was a wpa_gui
Back to top
View user's profile Send private message
willem-jan
n00b
n00b


Joined: 12 Sep 2021
Posts: 7

PostPosted: Tue Sep 14, 2021 4:18 pm    Post subject: Reply with quote

Thanks again for all your replies!

That actually sounded like a possible problem. But I don't use net.eth0 and alike. I also looked through every service including all the other runlevels, but none of them provide 'net' or 'net-online'. Also adding 'net-online' to did change anything help.

It almost feels like a bug in OpenRC since manually stopping NetworkManager works as expected (other services, like syncthing, that have 'depend net' stop first), but during shutdown OpenRC seems not to adhere to the order somehow. Also the error messages do give much of a clue...

I'm running out of options for this seemingly simple issue... I would indeed be willing to ditch NetworkManager but I remember I had issues during system installation with Netifrc and KDE.

Yes it is indeed laptop, hence have different WLAN, OpenVPN and ethernet configs that are 'dynamic'.

What would you recommend to use/do in this case?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3267
Location: Canada

PostPosted: Tue Sep 14, 2021 7:25 pm    Post subject: Reply with quote

willem-jan wrote:
Thanks again for all your replies!

That actually sounded like a possible problem. But I don't use net.eth0 and alike. I also looked through every service including all the other runlevels, but none of them provide 'net' or 'net-online'. Also adding 'net-online' to did change anything help.

It almost feels like a bug in OpenRC since manually stopping NetworkManager works as expected (other services, like syncthing, that have 'depend net' stop first), but during shutdown OpenRC seems not to adhere to the order somehow. Also the error messages do give much of a clue...

I'm running out of options for this seemingly simple issue... I would indeed be willing to ditch NetworkManager but I remember I had issues during system installation with Netifrc and KDE.

Yes it is indeed laptop, hence have different WLAN, OpenVPN and ethernet configs that are 'dynamic'.

What would you recommend to use/do in this case?



Irrespectively to the original problem, I use dhcpcd/wpa_supplicant for my laptop (which runs KDE)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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