mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-30 18:47:40 +03:00
Fix ulimit script
This commit is contained in:
parent
95daf0ba05
commit
832756be7d
@ -11,17 +11,32 @@ current_hard_limit=$(ulimit -Hn)
|
|||||||
TARGET_SOFT_LIMIT=65536
|
TARGET_SOFT_LIMIT=65536
|
||||||
TARGET_HARD_LIMIT=65536
|
TARGET_HARD_LIMIT=65536
|
||||||
|
|
||||||
|
echo "Current file limits - Soft: $current_soft_limit, Hard: $current_hard_limit"
|
||||||
|
|
||||||
if [ "$current_soft_limit" -lt "$TARGET_SOFT_LIMIT" ]; then
|
if [ "$current_soft_limit" -lt "$TARGET_SOFT_LIMIT" ]; then
|
||||||
# Attempt to set both soft and hard limits to the new value
|
if [ "$current_hard_limit" -lt "$TARGET_HARD_LIMIT" ]; then
|
||||||
# This requires sufficient privileges (e.g., running as root in the container)
|
if ! ulimit -Hn "$TARGET_HARD_LIMIT"; then
|
||||||
if ulimit -Hn "$TARGET_HARD" && ulimit -Sn "$TARGET_SOFT"; then
|
echo "Warning: Failed to set hard limit to $TARGET_HARD_LIMIT"
|
||||||
|
echo "This may require running as root or adjusting system limits"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ulimit -Sn "$TARGET_SOFT_LIMIT"; then
|
||||||
|
echo "Warning: Failed to set soft limit to $TARGET_SOFT_LIMIT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify the new limits
|
||||||
new_soft_limit=$(ulimit -Sn)
|
new_soft_limit=$(ulimit -Sn)
|
||||||
new_hard_limit=$(ulimit -Hn)
|
new_hard_limit=$(ulimit -Hn)
|
||||||
|
echo "New limits - Soft: $new_soft_limit, Hard: $new_hard_limit"
|
||||||
|
|
||||||
if [ "$new_soft_limit" -ne "$TARGET_SOFT_LIMIT" ] || [ "$new_hard_limit" -ne "$TARGET_HARD_LIMIT" ]; then
|
if [ "$new_soft_limit" -ne "$TARGET_SOFT_LIMIT" ] || [ "$new_hard_limit" -ne "$TARGET_HARD_LIMIT" ]; then
|
||||||
echo "Warning: Nofile limits were set, but not to the exact target values."
|
echo "Warning: Nofile limits were set, but not to the exact target values."
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "Warning: Failed to set new nofile limits."
|
echo "Successfully set file limits to target values"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Soft limit is already sufficient ($current_soft_limit >= $TARGET_SOFT_LIMIT)"
|
||||||
fi
|
fi
|
||||||
Loading…
Reference in New Issue
Block a user