What exactly happens under the hood when services are restarted in webGUI?

Joined
Aug 8, 2020
Messages
2
Take example NFS service.
I have a bit of a problem situation which requires restarting NFS service via webGUI to solve.

I've tried to set up watcher script waiting for a dependency and automatically running service nfsd restart once dependency is available, however this does not seem to be enough for some reason (running that manually won't do either) - which is why I'm wondering.

What does toggling service status in freenas web interface do exactly?

If you wonder, the problem is that I have active directory domain credentials for some nfs mounts due to cross platform uses, and active directory is not always available when system comes up until a bit later -> mounts fail until then.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Look in /usr/local/lib/python3.7/site-packages/middlewared/plugins/service.py. Line 827 begins the service stop process for nfsd. Line 836 begins the service start process for nfsd.

Code:
NFS service stop:
    async def _stop_nfs(self, **kwargs):
        await self._service("lockd", "stop", force=True, **kwargs)
        await self._service("statd", "stop", force=True, **kwargs)
        await self._service("nfsd", "stop", force=True, **kwargs)
        await self._service("mountd", "stop", force=True, **kwargs)
        await self._service("nfsuserd", "stop", force=True, **kwargs)
        await self._service("gssd", "stop", force=True, **kwargs)
        await self._service("rpcbind", "stop", force=True, **kwargs)

NFS service start:
    async def _start_nfs(self, **kwargs):
        await self.middleware.call("etc.generate", "nfsd")
        await self._service("rpcbind", "start", quiet=True, **kwargs)
        await self.middleware.call("nfs.setup_v4")
        await self._service("mountd", "start", quiet=True, **kwargs)
        await self._service("nfsd", "start", quiet=True, **kwargs)
        await self._service("statd", "start", quiet=True, **kwargs)
        await self._service("lockd", "start", quiet=True, **kwargs)
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
For your script, you should not try to stop and restart the components via service x stop/start. Rather, use midclt call service.stop "nfs" andmidclt call service.start "nfs", which does the same thing as the GUI.
 
Top