| 1 | Service Environment |
| 2 | ------------------- |
| 3 | |
| 4 | Finit supports sourcing environment variables from `/etc/default/*`, or |
| 5 | similar `--with-sysconfig=DIR`. This is a common pattern from SysV init |
| 6 | scripts, where the start-stop script is a generic script for the given |
| 7 | service, `foo`, and the options for the service are sourced from the |
| 8 | file `/etc/default/foo`. Like this: |
| 9 | |
| 10 | * `/etc/default/foo`: |
| 11 | |
| 12 | FOO_OPTIONS=--extra-arg="bar" -s -x |
| 13 | |
| 14 | * `/etc/finit.conf`: |
| 15 | |
| 16 | service [2345] env:-/etc/default/foo foo -n $FOO_OPTIONS -- Example foo daemon |
| 17 | |
| 18 | Here the service `foo` is started with `-n`, to make sure it runs in the |
| 19 | foreground, and the with the options found in the environment file. With |
| 20 | the `ps` command we can see that the process is started with: |
| 21 | |
| 22 | foo -n --extra-arg=bar -s -x |
| 23 | |
| 24 | > [!NOTE] |
| 25 | > The leading `-` in `env:` determines if Finit should treat a missing |
| 26 | > environment file as blocking the start of the service or not. When |
| 27 | > `-` is used, a missing environment file does *not* block the start. |