First create this file in /usr/lib/systemd/system
(replacing the values inside the <> brackets):
lavalink.service
[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