diff options
Diffstat (limited to 'zenserver')
| -rw-r--r-- | zenserver/zenserver.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index f81deb167..d8e46baf7 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -25,6 +25,12 @@ # include <zencore/windows.h> #endif +#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC +# include <sys/time.h> +# include <sys/resource.h> +# include <zencore/except.h> +#endif + #if ZEN_USE_MIMALLOC ZEN_THIRD_PARTY_INCLUDES_START # include <mimalloc-new-delete.h> @@ -1226,6 +1232,27 @@ main(int argc, char* argv[]) ZenWindowsService App(ServerOptions); return App.ServiceMain(); #else + +#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC + struct rlimit Limit; + int Error = getrlimit(RLIMIT_NOFILE, &Limit); + if (Error) + { + ZEN_WARN("failed getting rlimit RLIMIT_NOFILE, reason '{}'", MakeErrorCode(Error).message()); + } + else + { + struct rlimit NewLimit = Limit; + NewLimit.rlim_cur = 10240; + NewLimit.rlim_max = 10240; + Error = setrlimit(RLIMIT_NOFILE, &NewLimit); + if (Error != 0) + { + ZEN_WARN("failed to set RLIMIT_NOFILE limits from rlim_cur = {}, rlim_max {} to rlim_cur = {}, rlim_max {}, reason '{}'", Limit.rlim_cur, Limit.rlim_max, NewLimit.rlim_cur, NewLimit.rlim_max, MakeErrorCode(Error).message()); + } + } +#endif + if (ServerOptions.InstallService || ServerOptions.UninstallService) { throw std::runtime_error("Service mode is not supported on this platform"); |