Closed vilgotf closed 4 years ago
Only the superuser (root) can set the niceness of a process to a lower value. For security and convenience, this container will run as a non-root user, so changing niceness lower is not possible. Also, this container isn't actually launching or managing lavalink directly, it is launched and managed by Red-Discordbot itself (which is run by the non-root user).
What you could do (take this with a grain of salt: I have not tested this, don't know if it would work, nor know how to do it at the moment) is use the noaudio
tag, and then have lavalink run in a different linked container. Then, the bot can run on it's own, and you can somehow point the bot to use that external lavalink server instead. You'd be able to manually control the lavalinks niceness value.
Just curious, what are you running the bot on? Linux, Raspberry Pi, Windows?
I'm running this on a linux vps (fedora 31) so I was able to "solve" this by hacking together a script (running on the host) that greps the containers PIDs and renices them to -19. What I was hoping for was a solution where the containers starts at a higher privilege, sets the nice level to a user configuerd value and then drops privilege when launching red-discordbot (which should also set the nice level for any subproccess of red-discordbot [such as lavalink]).
Ah gotcha, you want the entire container to run at a specified niceness. Yeah, that's probably more doable. I'll look into that today!
Okay with 16efb6e I have added the capability to set a NICENESS
environment variable. Set that to -19, and since it's less than zero also enable the capability SYS_NICE
(--cap-add=SYS_NICE
). The bot (and Lavalink) should run with this niceness.
The build is done, so just pull and let me know if it works!
Fixes everything, thanks a lot!
The audio part of red-discord should be run at a lower nice value so that it doesn't lag. I don't know if just changing the nice of the lavalink is enough, but it's a good start.