Skip to content

Commit

Permalink
Systemd example (lavalink-devs#890)
Browse files Browse the repository at this point in the history
Co-authored-by: Toπ <[email protected]>
Co-authored-by: Freya Arbjerg <[email protected]>
  • Loading branch information
3 people authored Jul 13, 2023
1 parent 84fef2c commit 8bf9d98
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A [basic example bot](Testbot) is available.
- [Server configuration](#server-configuration)
- [Config](#config)
- [Binary](#binary)
- [Systemd Serivce](#systemd-service)
- [Docker](#docker)

</details>
Expand Down Expand Up @@ -219,6 +220,48 @@ Put an `application.yml` file in your working directory. ([Example here](Lavalin

Run with `java -jar Lavalink.jar` from the same directory

### Systemd Service

If you're using a Systemd-based Linux distribution you may want to install Lavalink as a background service. You will need to create a `lavalink.service` file inside `/usr/lib/systemd/system`. Create the file with the following template (replacing the values inside the `<>` brackets):
```ini
[Unit]
# Describe the service
Description=Lavalink Service

# Configure service order
After=syslog.target network.target

[Service]
# The user which will run Lavalink
User=<usr>

# The group which will run Lavalink
Group=<usr>

# Where the program should start
WorkingDirectory=</home/usr/lavalink>

# The command to start Lavalink
ExecStart=java -Xmx4G -jar </home/usr/lavalink>/Lavalink.jar

# Restart the service if it crashes
Restart=on-failure

# Delay each restart by 5s
RestartSec=5s

[Install]
# Start this service as part of normal system start-up
WantedBy=multi-user.target
```

To initiate the service, run
```shell
sudo systemctl daemon-reload
sudo systemctl enable lavalink
sudo systemctl start lavalink
```
In addition to the usual log files, you can also view the log with `sudo journalctl -u lavalink`.
### Docker

Docker images can be found under [packages](https://github.com/lavalink-devs/Lavalink/pkgs/container/lavalink) with old builds prior to `v3.7.4` being available on [Docker Hub](https://hub.docker.com/r/fredboat/lavalink/).
Expand Down Expand Up @@ -258,5 +301,4 @@ networks:
Run `docker compose up -d`. See [Docker Compose Up](https://docs.docker.com/engine/reference/commandline/compose_up/)

If your bot also runs in a docker container you can make that container join the lavalink network and use `lavalink` (service name) as the hostname to connect.
See [Docker Networking](https://docs.docker.com/network/) & [Docker Compose Networking](https://docs.docker.com/compose/networking/)

See [Docker Networking](https://docs.docker.com/network/) & [Docker Compose Networking](https://docs.docker.com/compose/networking/)

0 comments on commit 8bf9d98

Please sign in to comment.