docs: add instruction to run as service (#61)

This commit is contained in:
Shirshak 2022-01-05 16:44:07 +05:45 committed by GitHub
parent 850863e0e7
commit e3bb124873
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 0 deletions

View File

@ -75,6 +75,8 @@ Then run:
So you can `ssh myserver.com:5202` to ssh to your NAS.
4. If you want to use rathole as service please refer to this [docs](https://github.com/rapiz1/rathole/tree/main/examples/systemd). For windows we recommend NSSM using the guide from [here](https://www.paddingleft.com/2018/05/29/install-nodejs-program-as-windows-service-by-nssm/).
## Configuration
`rathole` can automatically determine to run in the server mode or the client mode, according to the content of the configuration file, if only one of `[server]` and `[client]` block is present, like the example in [Quickstart](#Quickstart).

View File

@ -0,0 +1,49 @@
## Systemd Configuration
We provide various systemd examples to make the management of rathole easy. You can find out various services file in
the current directory.
Here we will try to install server version. Same will apply for client etc.
Before procedding we need to have configuration ready. For that please refer to readme file. Also, @ in filename such as
`rathole@.service` carries [special meaning](https://superuser.com/questions/393423/the-symbol-and-systemctl-and-vsftpd) to enable multiple instances of rathole. If you are only hosting one instance then
feel free to use systemd config file that doesn't use @. Also, whenever we mention systemd config it means file that has *.service extension.
Here is simple instruction to install rathole server.
1. Create a service file:
```bash
wget https://github.com/rapiz1/rathole/blob/main/examples/systemd/ratholes@.service # download the file
sudo cp rathole@.service /lib/systemd/system/
```
2. Create the rathole configuration file we shall call it app1.toml.
```
sudo mkdir -p /etc/rathole
# Now create rathole config file called app1 inside /etc/rathole
```
If you don't want to use /etc/rathole you can tweak the systemd config file
```
ExecStart=/usr/bin/rathole -s /etc/rathole/%i.toml
```
_Note_: Don't replace `%i` becase it will be replaced by app1, app2 when we do `systemctl start rathole@app1` in coming
step.
3. Enable to service so it works automatically when computer is rebooted.
```bash
sudo systemctl enable ratholes@app1
```
4. Start the service
```bash
sudo systemctl enable ratholes@app1
```
You can use app1, app2 or whatever you like but make sure config file exists.