|
| 1 | +# systemd Service Unit |
| 2 | + |
| 3 | +This is an example of a systemd service that runs TigerBeetle. |
| 4 | +You will likely have to adjust it if you're deploying TigerBeetle. |
| 5 | + |
| 6 | +## Adjusting |
| 7 | + |
| 8 | +You can adjust multiple aspects of this systemd service. |
| 9 | +Each specific adjustment is listed below with instructions. |
| 10 | + |
| 11 | +It is not recommended to adjust some values directly in the service file. |
| 12 | +When this is the case, the instructions will ask you to instead use systemd's drop-in file support. |
| 13 | +Here's how to do that: |
| 14 | + |
| 15 | +1. Install the service unit in systemd (usually by adding it to `/etc/systemd/system`). |
| 16 | +2. Create a drop-in file to override the environment variables. |
| 17 | + Run `systemctl edit tigerbeetle.service`. |
| 18 | + This will bring you to an editor with instructions. |
| 19 | +3. Add your overrides. |
| 20 | + Example: |
| 21 | + ``` |
| 22 | + [Service] |
| 23 | + Environment=TIGERBEETLE_CACHE_GRID_SIZE=4GB |
| 24 | + Environment=TIGERBEETLE_ADDRESSES=0.0.0.0:3001 |
| 25 | + ``` |
| 26 | + |
| 27 | +### Pre-start script |
| 28 | + |
| 29 | +This service executes the `tigerbeetle-pre-start` script before starting TigerBeetle. |
| 30 | +This script is responsible for ensuring that a replica data file exists. |
| 31 | +It will create a data file if it doesn't exist. |
| 32 | + |
| 33 | +The script assumes that `/bin/sh` exists and points to a POSIX-compliant shell, and the `test` utility is either built-in or in the script's search path. |
| 34 | +If this is not the case, adjust the script's shebang. |
| 35 | + |
| 36 | +The service assumes that this script is installed in `/usr/local/bin`. |
| 37 | +If this is not the case, adjust the `ExecStartPre` line in `tigerbeetle.service`. |
| 38 | + |
| 39 | +### TigerBeetle executable |
| 40 | + |
| 41 | +The `tigerbeetle` executable is assumed to be installed in `/usr/local/bin`. |
| 42 | +If this is not the case, adjust both `tigerbeetle.service` and `tigerbeetle-pre-start` to use the correct location. |
| 43 | + |
| 44 | +### Environment variables |
| 45 | + |
| 46 | +This service uses environment variables to provide default values for a simple single-node cluster. |
| 47 | +To configure a different cluster structure, or a cluster with different values, adjust the values in the environment variables. |
| 48 | +It is **not recommended** to change these default values directly in the service file, because it may be important to revert to the default behavior later. |
| 49 | +Instead, use systemd's drop-in file support. |
| 50 | + |
| 51 | +### State directory and replica data file path |
| 52 | + |
| 53 | +This service configures a state directory, which means that systemd will make sure the directory is created before the service starts, and the directory will have the correct permissions. |
| 54 | +This is especially important because the service uses systemd's dynamic user capabilities. |
| 55 | +systemd forces the state directory to be in `/var/lib`, which means that this service will have its replica data file at `/var/lib/tigerbeetle/`. |
| 56 | +It is **not recommended** to adjust the state directory directly in the service file, because it may be important to revert to the default behavior later. |
| 57 | +Instead, use systemd's drop-in file support. |
| 58 | +If you do so, remember to also adjust the `TIGERBEETLE_DATA_FILE` environment variable, because it also hardcodes the `tigerbeetle` state directory value. |
| 59 | + |
| 60 | +Due to systemd's dynamic user capabilities, the replica data file path will not be owned by any existing user of the system. |
| 61 | + |
| 62 | +### Hardening configurations |
| 63 | + |
| 64 | +Some hardening configurations are enabled for added security when running the service. |
| 65 | +It is **not recommended** to change these, since they have additional implications on all other configurations and values defined in this service file. |
| 66 | +If you wish to change those, you are expected to understand those implications and make any other adjustments accordingly. |
0 commit comments