From 0dac698a33114ec987ccef9b1d2c8510ca9c62fe Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 19 Oct 2024 22:46:39 +0300 Subject: [PATCH] OF-2526: SystemD: limit resources and add openfire.slice --- .../src/dist/usr/lib/systemd/system/openfire.service | 9 +++++++++ .../src/dist/usr/lib/systemd/system/openfire.slice | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 distribution/src/dist/usr/lib/systemd/system/openfire.slice diff --git a/distribution/src/dist/usr/lib/systemd/system/openfire.service b/distribution/src/dist/usr/lib/systemd/system/openfire.service index 88b2596030..8a7fb98be5 100644 --- a/distribution/src/dist/usr/lib/systemd/system/openfire.service +++ b/distribution/src/dist/usr/lib/systemd/system/openfire.service @@ -12,6 +12,15 @@ ExecStart=/bin/bash -c '/usr/share/openfire/bin/openfire.sh ${DAEMON_OPTS}' Restart=on-failure RuntimeDirectory=openfire +# Specify resource limits in the slice +Slice=openfire.slice +# We expect a lot of connections from many clients so increase limit of file descriptiors +LimitNOFILE=50000 +# The Openfire is less important for CPU than system vital services +Nice=5 +# If not enough RAM then kill the Openfire first to preserve system vital services +OOMScoreAdjust=-100 + [Install] WantedBy=multi-user.target Alias=xmpp.service diff --git a/distribution/src/dist/usr/lib/systemd/system/openfire.slice b/distribution/src/dist/usr/lib/systemd/system/openfire.slice new file mode 100644 index 0000000000..eef22a5749 --- /dev/null +++ b/distribution/src/dist/usr/lib/systemd/system/openfire.slice @@ -0,0 +1,5 @@ +[Slice] +#MemoryAccounting=yes +#MemoryMax=95% +#CPUQuota=95% +#CPUAccounting=yes