mirror of
https://github.com/troglobit/finit.git
synced 2026-11-22 20:01:46 +00:00
Tie in service and condition documents with README
This is a first effort at cleaning up and consolidating all information about the new service state machine and how conditions control this state machine. Also, clarified and added sections for all documents regarding how services and conditions relate. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
6ff9cb2ff3
commit
1c0776b818
3 files changed
+78
-44
No files matched your search
@@ -162,20 +162,27 @@ Syntax:
|
||||
N is the runlevel number 1-9, where 6 is reserved for reboot.
|
||||
Default is 2.
|
||||
|
||||
* `run [LVLS] /path/to/cmd ARGS -- Optional description`
|
||||
* `run [LVLS] <COND> /path/to/cmd ARGS -- Optional description`
|
||||
One-shot command to run in sequence when entering a runlevel, with
|
||||
optional arguments and description. This command is guaranteed to be
|
||||
completed before running the next command.
|
||||
|
||||
* `task [LVLS] /path/to/cmd ARGS -- Optional description`
|
||||
* `task [LVLS] <COND> /path/to/cmd ARGS -- Optional description`
|
||||
One-shot like 'run', but starts in parallel with the next command
|
||||
|
||||
* `service [LVLS] /path/to/daemon ARGS -- Optional description`
|
||||
* `service [LVLS] <COND> /path/to/daemon ARGS -- Optional description`
|
||||
Service, or daemon, to be monitored and automatically restarted if it
|
||||
exits prematurely. Please note that you often need to provide a
|
||||
`--foreground` or `--no-background` argument to most daemons to
|
||||
prevent them from forking off a sub-process in the background.
|
||||
|
||||
```shell
|
||||
service [2345] <svc/sbin/zebra> /sbin/ospfd -- OSPF daemon
|
||||
```
|
||||
|
||||
For a detailed description of conditions, and how to debug them,
|
||||
see the [Finit Conditions](doc/conditions.md) document.
|
||||
|
||||
* `inetd service/proto[@iflist] <wait|nowait> [LVLS] /path/to/daemon args`
|
||||
Launch a daemon when a client initiates a connection on an Internet
|
||||
port. Available services are listed in the UNIX `/etc/services` file.
|
||||
@@ -227,7 +234,7 @@ Syntax:
|
||||
sure to call the configure script with `--enable-embedded` if this
|
||||
is what you want.
|
||||
|
||||
* `console <DEV | /path/to/cmd [args]>`
|
||||
* `console <DEV | /path/to/cmd [args]`
|
||||
Some embedded systems have a dedicated serial console/service port.
|
||||
This command tells finit to not start getty directly, since there may
|
||||
not be anyone there. To save RAM and CPU finit instead displays a
|
||||
@@ -284,15 +291,18 @@ call `finit q`, but that has been deprecated with the `initctl` tool).
|
||||
Any service read from this directory is flagged as a dynamic service, so
|
||||
changes to or removal of `/etc/finit.d/*.conf` files, is detected.
|
||||
|
||||
- If a service's `.conf` file has been removed, the service is stopped.
|
||||
- If the file is modified, the service is reloaded, stopped and started.
|
||||
- If service 1 is reloaded, and service 2 depends on service 1, then
|
||||
service 2 will also be reloaded. Note: service dependencies must be
|
||||
declared for each service for this to work. For more info on this,
|
||||
see the separate document [Finit Conditions](doc/conditions.md).
|
||||
On `initctl reload` the following is checked for all services:
|
||||
|
||||
- If a service's `.conf` file has been removed, or its conditions are no
|
||||
longer satisifed, the service is stopped.
|
||||
- If the file is modified, or a service it depends on has been reloaded,
|
||||
the service is reloaded (stopped and started).
|
||||
- If a new service is added it is automatically started — respecting
|
||||
runlevels and return values from any callbacks.
|
||||
|
||||
For more info on the different states of a service, see the separate
|
||||
document [Finit Services](doc/service.md).
|
||||
|
||||
The `/etc/finit.d` directory was previously the default Finit `runparts`
|
||||
directory. Finit no longer has a default `runparts`, so make sure to
|
||||
update your setup, or the finit configuration, accordingly.
|
||||
@@ -840,7 +850,7 @@ The default install does not setup finit as the system default
|
||||
`/sbin/init`, neither does it setup an initial `/etc/finit.conf`.
|
||||
|
||||
It is assumed that users of finit are competent enough to either setup
|
||||
finit as their default `/sbin/init` or alter their respective Grub,
|
||||
finit as their default `/sbin/init` or alter their respective GRUB,
|
||||
LOADLIN, LILO, U-Boot/Barebox or RedBoot boot loader configuration to
|
||||
give the kernel the following extra command line:
|
||||
|
||||
|
||||
+37
-18
@@ -1,7 +1,7 @@
|
||||
Finit Conditions
|
||||
================
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
Table of Contents
|
||||
@@ -17,11 +17,12 @@ Table of Contents
|
||||
Introduction
|
||||
------------
|
||||
|
||||
In addition to runlevels, services can declare user-defined conditions
|
||||
as dependencies. Conditions are specified within angle brackets (<>) in
|
||||
the service stanza. Multiple conditions may be specified separated by
|
||||
comma. Conditions are AND'ed during evaluation, i.e. all conditions
|
||||
must be satisfied in order for a service to run.
|
||||
In addition to declaring allowed runlevels per service, it is also
|
||||
possible to declare user-defined conditions as dependencies. Conditions
|
||||
are specified within angle brackets (<>) in the service stanza.
|
||||
Multiple conditions may be specified separated by comma. Conditions are
|
||||
AND'ed during evaluation, i.e. all conditions must be satisfied in order
|
||||
for a service to run.
|
||||
|
||||
|
||||
**Example:**
|
||||
@@ -39,8 +40,8 @@ service's pidfile being created.
|
||||
Triggering
|
||||
----------
|
||||
|
||||
Conditions are triggered by using the `emit` command of the `initctl`
|
||||
control tool.
|
||||
Conditions are triggered either by plugins or by using the `emit`
|
||||
command of the `initctl` control tool.
|
||||
|
||||
* `initctl emit +your/cond/here`
|
||||
|
||||
@@ -61,20 +62,38 @@ new (or possibly unchanged) state of it.
|
||||
Built-in Conditions
|
||||
-------------------
|
||||
|
||||
Finit is distributed with the `pidfile`-plugin. If enabled, it will
|
||||
watch `/var/run/` for pidfiles created by services that it controls
|
||||
and set a corresponding condition in the `svc/` namespace.
|
||||
Finit is distributed with a `pidfile` and `netlink` plugin. If enabled,
|
||||
the `pidfile` plugin watches `/var/run/` for PID files created by
|
||||
monitored services, and sets a corresponding condition in the `svc/`
|
||||
namespace. Similarily, the `netlink` plugin provides basic conditions
|
||||
for when an interface is brought up/down and when a default route
|
||||
(gateway) is set.
|
||||
|
||||
For example, if Finit starts the `/sbin/netd` daemon and it creates the
|
||||
file `/var/run/netd.pid`, the condition `svc/sbin/netd` is satisfied.
|
||||
If the file is removed, the condition is cleared.
|
||||
With the example listed above, finit does not start the `/sbin/netd`
|
||||
daemon until `setupd` and `zebra` has started *and* created their PID
|
||||
files. Which they do when they completed their main tasks of setting up
|
||||
VLANs, bridge, interfaces, etc. When `netd` in turn starts up it
|
||||
creates the file `/var/run/netd.pid`, and the condition `svc/sbin/netd`
|
||||
is satisfied. When the file is removed, the condition is cleared.
|
||||
|
||||
The full path to the dependency is needed by finit to match the PID file
|
||||
to a monitored process.
|
||||
|
||||
Built-in conditions:
|
||||
|
||||
- `svc/<PATH>`
|
||||
- `net/route/default`
|
||||
- `net/<IFNAME>/exist`
|
||||
- `net/<IFNAME>/up`
|
||||
|
||||
Note: `up` is administratively up, `IFF_UP`, not link up, `IFF_RUNNING`.
|
||||
|
||||
|
||||
Debugging
|
||||
---------
|
||||
|
||||
If a service is not being started as it should, the problem might be
|
||||
that one of its conditions are not in the expected state. Use the
|
||||
that one of its conditions is not in the expected state. Use the
|
||||
command `initctl status` to inspect service status. Services in the
|
||||
`ready` state are pending a condition.
|
||||
|
||||
@@ -102,9 +121,9 @@ Internals
|
||||
|
||||
A condition is always in one of three states:
|
||||
|
||||
* `on`: The condition is asserted.
|
||||
* `off`: The condition is deasserted.
|
||||
* `flux`: The conditions state is unknown.
|
||||
* `on` (+): The condition is asserted.
|
||||
* `off` (-): The condition is deasserted.
|
||||
* `flux` (~): The conditions state is unknown.
|
||||
|
||||
All conditions that have not explicitly been set are interpreted as
|
||||
being in the `off` state.
|
||||
|
||||
+20
-15
@@ -1,29 +1,34 @@
|
||||
# Services
|
||||
Finit Services
|
||||
==============
|
||||
|
||||
## State Machine
|
||||

|
||||
|
||||

|
||||
State Machine
|
||||
-------------
|
||||
|
||||
A service is bound to a state machine that is in one of six (6)
|
||||
states. For `run`s and `task`s there is an additional end state called
|
||||
`DONE`, not shown in the diagram for brevity. All services start in
|
||||
the `HALTED` state.
|
||||
A service is bound to a state machine that is in one of six (6) states.
|
||||
For `run`s and `task`s there is an additional end state called `DONE`,
|
||||
not shown in the diagram for brevity. Services start in the `HALTED`
|
||||
state.
|
||||
|
||||
The current state depends on the two following conditions:
|
||||
|
||||
* `E`: Service enabled. In order for `E` to be satisfied, the service
|
||||
must be allowed to run in the current runlevel and must not be
|
||||
blocked. A service may be blocked for several reasons:
|
||||
|
||||
- The user has manually stopped the service using `initctl stop
|
||||
JOB`.
|
||||
|
||||
- The binary repeatedly dies after being started. I.e. keeps
|
||||
crashing.
|
||||
blocked. A service may be blocked for several reasons:
|
||||
|
||||
- The user has manually stopped the service using `initctl stop JOB`
|
||||
- The binary repeatedly dies after being started. I.e. keeps crashing.
|
||||
- The binary is missing in the filesystem.
|
||||
|
||||
* `C`: Service conditions are satisfied.
|
||||
* `C`: Service conditions are satisfied:
|
||||
|
||||
- `on` (+): The condition is asserted.
|
||||
- `off` (-): The condition is deasserted.
|
||||
- `flux` (~): The conditions state is unknown.
|
||||
|
||||
For a detailed description of conditions, and how to debug them,
|
||||
see the [Finit Conditions](conditions.md) document.
|
||||
|
||||
<!--
|
||||
-- Local Variables:
|
||||
|
||||
Reference in new issue
Block a user