2022-01-05 12:19:45 +01:00
## Systemd Unit Examples
2022-01-05 11:59:07 +01:00
2022-01-05 12:19:45 +01:00
The directory lists some systemd unit files for example, which can be used to run `rathole` as a service on Linux.
2022-01-05 11:59:07 +01:00
2022-01-05 12:19:45 +01:00
[The `@` symbol in name of unit files ](https://superuser.com/questions/393423/the-symbol-and-systemctl-and-vsftpd ) such as
`rathole@.service` facilitates the management of multiple instances of `rathole` .
2022-01-05 11:59:07 +01:00
2022-01-05 12:19:45 +01:00
For the naming of the example, `ratholes` stands for `rathole --server` , and `ratholec` stands for `rathole --client` , `rathole` is just `rathole` .
2022-01-05 11:59:07 +01:00
2022-01-26 14:11:48 +01:00
Assuming that `rathole` is installed in `/usr/bin/rathole` , and the configuration file is in `/etc/rathole/app1.toml` , the following steps shows how to run an instance of `rathole --server` .
2022-01-05 11:59:07 +01:00
2022-01-05 12:19:45 +01:00
1. Create a service file.
2022-01-05 11:59:07 +01:00
```bash
2022-01-05 12:19:45 +01:00
sudo cp ratholes@.service /etc/systemd/system/
2022-01-05 11:59:07 +01:00
```
2022-01-05 12:19:45 +01:00
2. Create the configuration file `app1.toml` .
2022-01-05 11:59:07 +01:00
2022-01-05 12:19:45 +01:00
```bash
2022-01-05 11:59:07 +01:00
sudo mkdir -p /etc/rathole
2022-01-05 12:19:45 +01:00
# And create the configuration file named `app1.toml` inside /etc/rathole
2022-01-05 11:59:07 +01:00
```
2022-01-05 12:19:45 +01:00
3. Enable and start the service
2022-01-05 11:59:07 +01:00
```bash
2022-01-05 12:19:45 +01:00
sudo systemctl daemon-reload # Make sure systemd find the new unit
sudo systemctl enable ratholes@app1 --now
2022-01-05 11:59:07 +01:00
```
2022-01-05 12:19:45 +01:00
And if there's another configuration named `app2.toml` in `/etc/rathole` , then
`sudo systemctl enable ratholes@app2 --now` can start an instance for that configuration.
2022-01-05 11:59:07 +01:00
2022-01-05 12:19:45 +01:00
The same applies to `rathole --client` and `rathole` .