LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   'Active (enabled)' status - what is it, how to avoid it ? (https://www.linuxquestions.org/questions/centos-111/active-enabled-status-what-is-it-how-to-avoid-it-4175663908/)

Shaggy1 11-08-2019 07:41 AM

'Active (enabled)' status - what is it, how to avoid it ?
 
Hi
Having just installed 7.7.1908 I notice that the nfs service (also network service and probably others) are marked as Active (enabled) when the status is queried:

systemctl status nfs
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
Active: active (exited) since Wed 2019-11-06 12:34:47 GMT; 1 day 2h ago
Process: 2181 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS)
Process: 1968 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 1927 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 1968 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service

Nov 06 12:34:47 lb-cam-bca-kstest systemd[1]: Starting NFS server and services...
Nov 06 12:34:47 lb-cam-bca-kstest systemd[1]: Started NFS server and services.


This link:
https://unix.stackexchange.com/quest...ystemd-service
tells me:

"State active (exited) means that systemd has successfully run the commands but that it does not know there is a daemon to monitor.

If there is you must define it in the unit file by configuring the Type and ExecStart options appropriately according to whether the process you start is the main proces, forks child processes and exits etc."

It seems there is already a Unit file for nfs in /usr/lib/systemd/system/nfs.service:

Type and ExecStart are set as follows:
Type=oneshot
ExecStartPre=-/usr/sbin/exportfs -r
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS
ExecStartPost=-/bin/sh -c 'if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi'


Is this status to be expected for nfs on centos 7?

Does anyone know how to get systemd to recognise the nfs service ?

Given systemd does not recognise nfs should I be using a different service to configure nfs ?

berndbausch 11-08-2019 05:19 PM

Quote:

Originally Posted by Shaggy1 (Post 6055497)

Does anyone know how to get systemd to recognise the nfs service ?

Given systemd does not recognise nfs should I be using a different service to configure nfs ?

I start nfs with systemctl start nfs.

What do you mean by "recognise"?
What problem do you have?
Have you read the documentation?

scasey 11-08-2019 05:33 PM

Not sure what you're asking about. The subject asks about "enabled" and then you talk about "exited"

It appears that the service has been started:
Code:

Nov 06 12:34:47 lb-cam-bca-kstest systemd[1]: Starting NFS server and services...
Nov 06 12:34:47 lb-cam-bca-kstest systemd[1]: Started NFS server and services.


Shaggy1 11-11-2019 09:28 AM

Hi
Thank you for your replies

> Not sure what you're asking about. The subject asks about "enabled" and then you talk about "exited"
Sorry the 'Active (enabled)' in the question was a mistake, I meant 'Active (exited)'.

> What problem do you have?
As mentioned the service does seem to be started, so there does not seem to be an immediate problem with the service itself.

I was, however, wondering:
a) exactly what it is which causes a service to have this status and why.
Most services when running indicate: 'active (running)'
(and also the legacy command 'service <servicename> status' successfully forwards to systemctl - in the case if nfs this does not work)
b) whether this matters, or is likely to be an issue.
c) if it is likely to be an issue how can I stop it from being so

> What do you mean by "recognise"?
I was referring to the statement "does not know there is a daemon to monitor." in the link I mentioned.
How do I get it to know there is a daemon to monitor ?

> Have you read the documentation?
I did read through this documentation, but I could not see any reference to 'active (exited)' status or how to tell it there is a daemon to monitor. I could well have missed, so will look again more thoroughly. There is also a link:
https://access.redhat.com/documentat...emd-unit_files
which may well be telling me the answer, but I'm not seeing it, so I'll try that again.

berndbausch 11-11-2019 09:49 AM

Quote:

Originally Posted by Shaggy1 (Post 6056424)
a) exactly what it is which causes a service to have this status and why.
Most services when running indicate: 'active (running)'
b) whether this matters, or is likely to be an issue.
c) if it is likely to be an issue how can I stop it from being so

In short, all is fine. I will try to explain (as much as I understand it).

The nfs service definition includes
Code:

Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/sbin/exportfs -r
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS

oneshot means that the service is considered to be up ("active") after the main process rpc.nfsd exits. I guess that rpc.nfsd starts one or more processes, then exits, so that there is no process that the nfs service can monitor. Which does not mean that the service failed to start.
Apart from the call to rpc.nfsd, the purpose of the nfs service is probably to start other services as dependencies.

With RemainAfterExit, the service is considered active even when all its processes exit, not only the main one (as far as I understand this).

See https://www.freedesktop.org/software...d.service.html for more details.

Shaggy1 11-18-2019 04:37 AM

Thank you very much berndbausch for this explanation - that clarifies it form me.


All times are GMT -5. The time now is 07:52 AM.