Host via pm2

  1. Install pm2

    • npm install -g pm2 / yarn add --global pm2

  2. Go into the root directory of Lavalink.jar, and execute the following

pm2 start --name "Lavalink Server" --max-memory-restart 4G java -- -jar Lavalink.jar

now on pm2 list you can see the server (as well it's process ID)

with pm2 stop <ID> you can stop it

with pm2 start <ID> you can start it

on 4 Gigabyte of memory usage, lavalink automatically stops and restart itsself

with pm2 delete <ID> you can stop + delete the lavalink server process (not the directory)

What about the logs?

Pm2 has packages, to auto-rotate and auto-flush the logs to save storage!

pm2 flush # to flush all current logs
pm2 install pm2-logrotate # pm2 install a plugin
pm2 set pm2-logrotate:max_size 10M # config it for 10mb of logs
pm2 set pm2-logrotate:compress true # compress the logs
pm2 set pm2-logrotate:rotateInterval '0 */1 * * *' # rotate logs every hr (cron-job)

I made that Pm2 + Linux Tutorial Cheatsheet, if you ever need it!

Last updated