From 1f55d38911cec5e597e7b10cc7324804c2ba063f Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 16 May 2017 08:50:53 -0700 Subject: [PATCH] Add systemd ulimit override function and set an override for NOFILE This sets our default ulimit NOFILE to 2048, which is double what we set things like mysql'd max_connections to. Change-Id: I5126bed1e6b9f8c64db00eae4151ac61e47b1bf8 --- functions | 16 ++++++++++++++++ stack.sh | 3 +++ stackrc | 3 +++ 3 files changed, 22 insertions(+) diff --git a/functions b/functions index f842f63038..bc2d26b496 100644 --- a/functions +++ b/functions @@ -720,6 +720,22 @@ function enable_kernel_bridge_firewall { } +# Set a systemd system override +# +# This sets a system-side override in system.conf. A per-service +# override would be /etc/systemd/system/${service}.service/override.conf +function set_systemd_override { + local key="$1" + local value="$2" + + local sysconf="/etc/systemd/system.conf" + iniset -sudo "${sysconf}" "Manager" "$key" "$value" + echo "Set systemd system override for ${key}=${value}" + + sudo systemctl daemon-reload +} + + # Restore xtrace $_XTRACE_FUNCTIONS diff --git a/stack.sh b/stack.sh index d6837ef5d0..e83eaea326 100755 --- a/stack.sh +++ b/stack.sh @@ -765,6 +765,9 @@ install_infra # Phase: pre-install run_phase stack pre-install +# NOTE(danms): Set global limits before installing anything +set_systemd_override DefaultLimitNOFILE ${ULIMIT_NOFILE} + install_rpc_backend restart_rpc_backend diff --git a/stackrc b/stackrc index 35856ca73e..ea1bcdf3f0 100644 --- a/stackrc +++ b/stackrc @@ -925,6 +925,9 @@ fi # ``LOGDIR`` is always set at this point so it is not useful as a 'enable' for service logs # ``SCREEN_LOGDIR`` may be set, it is useful to enable the compat symlinks +# System-wide ulimit file descriptors override +ULIMIT_NOFILE=${ULIMIT_NOFILE:-2048} + # Local variables: # mode: shell-script # End: