Skip to content

Commit

Permalink
set nofile limit for Docker containers
Browse files Browse the repository at this point in the history
  • Loading branch information
trikko committed Apr 26, 2024
1 parent 73b0648 commit 42d539b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions source/serverino/main.d
Expand Up @@ -123,6 +123,20 @@ template ServerinoLoop(Modules...)

int mainServerinoLoop(string[] args)
{

// Docker container has a too generous limit of open files, it slows down the server
version(Posix)
{
import core.sys.posix.sys.resource : rlimit, setrlimit, getrlimit, RLIMIT_NOFILE;
rlimit rlim;
getrlimit(RLIMIT_NOFILE, &rlim);

if (rlim.rlim_cur > 65536)
rlim.rlim_cur = 4096;

setrlimit(RLIMIT_NOFILE, &rlim);
}

// Enable terminal colors on older windows
version(Windows)
{
Expand Down

0 comments on commit 42d539b

Please sign in to comment.