mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-05 20:11:14 +08:00
fix: Implement Enhanced File Descriptor Limit Handling in Shell Script (#1160)
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
parent
daf58715ed
commit
8dd6a05d38
@ -18,11 +18,11 @@ set -o errexit
|
||||
set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
ulimit -n 200000
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
openim::util::set_max_fd 200000
|
||||
|
||||
SERVER_NAME="openim-msggateway"
|
||||
|
||||
function openim::msggateway::start()
|
||||
|
@ -18,11 +18,11 @@ set -o errexit
|
||||
set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
ulimit -n 200000
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
openim::util::set_max_fd 200000
|
||||
|
||||
SERVER_NAME="openim-msgtransfer"
|
||||
|
||||
function openim::msgtransfer::start()
|
||||
|
@ -1250,6 +1250,38 @@ function openim::util::gencpu() {
|
||||
echo $cpu_count
|
||||
}
|
||||
|
||||
function openim::util::set_max_fd() {
|
||||
local desired_fd=$1
|
||||
local max_fd_limit
|
||||
|
||||
# Check if we're not on cygwin or darwin.
|
||||
if [ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "cygwin" ] && [ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "darwin" ]; then
|
||||
# Try to get the hard limit.
|
||||
max_fd_limit=$(ulimit -H -n)
|
||||
if [ $? -eq 0 ]; then
|
||||
# If desired_fd is 'maximum' or 'max', set it to the hard limit.
|
||||
if [ "$desired_fd" = "maximum" ] || [ "$desired_fd" = "max" ]; then
|
||||
desired_fd="$max_fd_limit"
|
||||
fi
|
||||
|
||||
# Check if desired_fd is less than or equal to max_fd_limit.
|
||||
if [ "$desired_fd" -le "$max_fd_limit" ]; then
|
||||
ulimit -n "$desired_fd"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Warning: Could not set maximum file descriptor limit to $desired_fd"
|
||||
fi
|
||||
else
|
||||
echo "Warning: Desired file descriptor limit ($desired_fd) is greater than the hard limit ($max_fd_limit)"
|
||||
fi
|
||||
else
|
||||
echo "Warning: Could not query the maximum file descriptor hard limit."
|
||||
fi
|
||||
else
|
||||
echo "Warning: Not attempting to modify file descriptor limit on Cygwin or Darwin."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function openim::util::gen_os_arch() {
|
||||
# Get the current operating system and architecture
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
|
Loading…
x
Reference in New Issue
Block a user