File: service.md

package info (click to toggle)
finit 4.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,216 kB
  • sloc: ansic: 17,060; sh: 6,281; makefile: 532
file content (57 lines) | stat: -rw-r--r-- 2,181 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Starting & Monitoring
=====================

Finit can start and monitor the following types of daemons:

* Forks to background, creates a PID file
* Runs in foreground and signals ready by:
  - creating a PID file
  - does not create a PID file -- Finit can create it for you (optional)
  - [other mechanism][1] (systemd, s6)

Finit can *not* start and monitor a daemon that:

* Forks to background and does *not* create a PID file

|   | Forking | Creates PID File | Finit creates PID File |
|---|---------|------------------|------------------------|
| ✔ | Yes     | Yes              | No                     |
| ✔ | No      | Yes              | No                     |
| ✔ | No      | No               | Yes, optionally        |
| ✘ | Yes     | No               | No                     |

> [!NOTE]
> PID files is one mechanism used to assert conditions to synchronize
> the start and stop of other, dependent, services.  Other mechanisms
> are described in the [Service Synchronization][1] section.

### Forks to bg w/ PID file

There are two syntax variants, type 1 and type 2.  The former is the
traditional one used also for `sysv` start/stop scripts, and the latter
is inspired by systemd, with a twist -- it lets Finit guess the pifdile
to look for based on the standard path and the basename of the command.

    service pid:!/run/serv.pid serv       -- Forking service, type 1
    service type:forking       serv       -- Forking service, type 2

In this example the resulting files to watch for are `/run/serv.pid` and
`/var/run/serv.pid`, respectively.  On most modern Linux systems this is
the same directory (`/var/run` is a symlink to `../run`).

### Runs in fg w/ PID file

    service                    serv -n -p -- Foreground service w/ PID file

### Runs in fg w/o PID file

Same as previous, but we tell Finit to create the PID file, because we
need it to synchronize start/stop of a dependent service.

    service pid:/run/serv.pid  serv -n    -- Foreground service w/o PID file

### Runs in fg w/ custom PID file

    service pid:/run/servy.pid serv -n -p -P /run/servy.pid -- Foreground service w/ custom PID file

[1]: config/service-sync.md