Mailing List Archive

Question about runlevels.
Hi,

Do services started in the "boot" runlevel continue to run in the
"default" runlevel?

Or do they get stopped as part of transitioning from the "boot" runlevel
to the "default" runlevel? (Or any other runlevel that doesn't include
the service.

I'm wondering about having two things that are very similar (as in use
the same ports), but distinctly different (different configurations)
with the following:

myService-boot | boot
myService-default | default

Will myService-boot start and run during boot, then stop when the system
goes into the default runlevel?

My expectation is that OpenRC will (try to) start myService-default when
the system enters the default runlevel. But it will fail if
myService-boot is still running.



--
Grant. . . .
unix || die
Re: Question about runlevels. [ In reply to ]
On 2021.03.18 14:36, Grant Taylor wrote:
> Hi,
>
> Do services started in the "boot" runlevel continue to run in the
> "default" runlevel?
>
> Or do they get stopped as part of transitioning from the "boot"
> runlevel to the "default" runlevel? (Or any other runlevel that
> doesn't include the service.
>
> I'm wondering about having two things that are very similar (as in
> use the same ports), but distinctly different (different
> configurations) with the following:
>
> myService-boot | boot
> myService-default | default
>
> Will myService-boot start and run during boot, then stop when the
> system goes into the default runlevel?
>
> My expectation is that OpenRC will (try to) start myService-default
> when the system enters the default runlevel. But it will fail if
> myService-boot is still running.
That is my expectation. I don't see any automatic stopping of
services. Even the services in the shutdown runlevel get started -
even though their starting is actually stopping other stuff.

Do an rc-status (you might need to explicitly do "rc-status boot") and
see all the boot runlevel services are still running (unless you
explicitly stopped them.) Can you explicitly set up myService-default
to explicitly check if myService-boot is running, and if so, stop it
before starting itself?

Jack
Re: Question about runlevels. [ In reply to ]
On 18/03/2021 18:36, Grant Taylor wrote:
> Do services started in the "boot" runlevel continue to run in the
> "default" runlevel?
>
Yes

> Or do they get stopped as part of transitioning from the "boot" runlevel
> to the "default" runlevel?  (Or any other runlevel that doesn't include
> the service.
>
Generally yes, when changing from one runlevel to another OpenRC will
stop all services from the previous (current) runlevel and start the
services for the next (new) runlevel.

However, my understanding is that the `boot' and `sysinit' runlevels are
"special" and services started there are also included in all
"non-special" runlevels.

In your case, `myService-boot' should remain active in `default' along
with `myService-default'. You can double check that by running

$ rc-status


> I'm wondering about having two things that are very similar (as in use
> the same ports), but distinctly different (different configurations)
> with the following:
>
...
> My expectation is that OpenRC will (try to) start myService-default when
> the system enters the default runlevel.  But it will fail if
> myService-boot is still running.
>
It's difficult to say without understanding what they do and their end
goal. It also depends on how the services are coded. If they try to bind
to the same port then yes, chances are that `myService-default' will
fail at this point as the former would still be running.

If that's the case, one option is to separate their responsibilities
and/or make `myService-default' depend on `myService-boot' and have it
leverage whatever it is that `myService-boot' already provides.

- V
Re: Question about runlevels. [ In reply to ]
On 3/18/21 12:54 PM, Victor Ivanov wrote:
> Yes

Okay.

> Generally yes, when changing from one runlevel to another OpenRC will
> stop all services from the previous (current) runlevel and start the
> services for the next (new) runlevel.

Good.

> However, my understanding is that the `boot' and `sysinit' runlevels are
> "special" and services started there are also included in all
> "non-special" runlevels.

Ah.

> In your case, `myService-boot' should remain active in `default' along
> with `myService-default'. You can double check that by running
>
>      $ rc-status

Hum.

I'm not seeing any overlap between services in the boot runlevel and
services still running in the default runlevel.

cat <(rc-status | egrep "^ " | sort | awk '{print $1}') <(rc-update |
grep boot | awk '{print $1}' | sort) | sort | uniq -c

All the services are listed one time.

If any of the boot services are still running as a default service, I
would expect their count to be two.

> It's difficult to say without understanding what they do and their end
> goal. It also depends on how the services are coded. If they try to bind
> to the same port then yes, chances are that `myService-default' will
> fail at this point as the former would still be running.

It doesn't really matter.

My question was about a boot service continuing to run in the default
runlevel or not. It doesn't matter what myService-boot and
myService-default are. They could be zfs-mount and sshd.

I'm only interested in if myService-boot continues to run in the default
runlevel or not.

myService-boot | boot
myService-default | default

> If that's the case, one option is to separate their responsibilities
> and/or make `myService-default' depend on `myService-boot' and have it
> leverage whatever it is that `myService-boot' already provides.

Immaterial.



--
Grant. . . .
unix || die