OpenRC / openrc

The OpenRC init system
BSD 2-Clause "Simplified" License
1.45k stars 246 forks source link

Descriptions of need, use, and want functions are confusing. #303

Open konsolebox opened 5 years ago

konsolebox commented 5 years ago

need declares a hard dependency - net always needs to be started before this service does

Does that mean dependency doesn't have to be in the current runlevel?

use is a soft dependency - if dns, logger or netmount is in this runlevel start it before, but we don't care if it's not in this runlevel.

And we don't care if it doesn't start because it's not in the current runlevel? And to be more explicit, we don't start it?

want is between need and use - try to start coolservice if it is installed on the system, regardless of whether it is in the runlevel, but we don't care if it starts.

You mean "and we also don't care if it starts"? It looks the same as use unless you add "we don't start it" to use.

In my opinion the descriptions here need to be completely redone for clarification. Showing a table to compare feature or behavior differences would be better.

Also we should describe how the functions behave with virtual dependencies created by provide.

konsolebox commented 5 years ago

This is one of the ways I think it can be better written so far. Please improve. It's based on how I currently interpret the source code.

An explicit description on how these directives behave when a "dependency" has already started in another runlevel should also be added. There's also no description on how virtual dependencies are treated vs. real ones yet.

need declares a hard dependency - "net" always needs to be started before this service does. It doesn't have to be in the same runlevel.

want is similar to need that it starts "coolservice" regardless if it's in the same runlevel, but it doesn't matter if "coolservice" starts.

use is similar to need that it requires "dns", "logger", and "netmount" to start but only if they're in the same runlevel. We don't care if all or one of them don't get started because they're not in the same runlevel.

before declares that we need to be started before another service just in case the other service is in the same runlevel.

after declares that we need to be started after another service in case other service is in the same runlevel. The difference between this and use is that this one doesn't create an explicit dependency. So on calling stop, the two are independent.

konsolebox commented 5 years ago

I looked at this issue again, and I'm no longer sure which directive requires a dependency to successfully start (when they are called to, and when calling them is applicable) before the calling service does. It seems that only need requires a dependency to successfully start, but that doesn't make sense. use should do as well, and after should not. I'm not sure about want. All of them requiring a dependency to successfully start (when applicable) would also not make sense.

Anyway I think it should be explicitly stated if a directive requires a dependency to start successfully as well, like this one:

need declares a hard dependency - "net" always needs to be successfully started before this service does. It doesn't have to be in the same runlevel.

want is similar to need that it starts "coolservice" regardless if it's in the same runlevel, but it doesn't matter if "coolservice" has successfully started.

use is similar to need that it requires "dns", "logger", and "netmount" to start but only if they're in the same runlevel. We don't care if all or one of them don't get started because they're not in the same runlevel, but we do care that they successfully start if they are.

before declares that we need to be started before another service just in case the other service is in the same runlevel.

after declares that we need to be started after another service in case other service is in the same runlevel but we don't care if it successfully starts, and we're not affected by its stop.

I think need can also be clarified further on how a service gets started before it:

need declares a hard dependency - "net" always needs to be successfully started before this service does. The "net" service gets started if it hasn't started yet regardless if the service is in the same runlevel, or if the service is not declared anywhere.