2024-08-23 05:37:52 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
sysctl vm.overcommit_memory=1 || true
|
|
|
|
sysctl net.core.somaxconn=1024 || true
|
|
|
|
|
|
|
|
PW_ARG=""
|
|
|
|
if [[ ! -z "${REDIS_PASSWORD}" ]]; then
|
|
|
|
PW_ARG="--requirepass $REDIS_PASSWORD"
|
|
|
|
fi
|
|
|
|
|
2024-10-08 23:03:37 +08:00
|
|
|
: ${MAXMEMORY_POLICY:="noeviction"}
|
2024-08-23 05:37:52 +08:00
|
|
|
: ${APPENDONLY:="no"}
|
2024-10-08 23:03:37 +08:00
|
|
|
: ${FLY_VM_MEMORY_MB:=$(($(grep MemTotal /proc/meminfo | awk '{print $2}') / 1024))}
|
2024-08-23 05:37:52 +08:00
|
|
|
if [ "${NOSAVE}" = "" ] ; then
|
|
|
|
: ${SAVE:="3600 1 300 100 60 10000"}
|
|
|
|
fi
|
2024-10-08 23:03:37 +08:00
|
|
|
# Set maxmemory to 80% of RAM
|
2024-08-23 05:37:52 +08:00
|
|
|
MAXMEMORY=$(($FLY_VM_MEMORY_MB*80/100))
|
|
|
|
|
|
|
|
mkdir /data/redis
|
|
|
|
|
|
|
|
redis-server $PW_ARG \
|
|
|
|
--dir /data/redis \
|
|
|
|
--maxmemory "${MAXMEMORY}mb" \
|
|
|
|
--maxmemory-policy $MAXMEMORY_POLICY \
|
|
|
|
--appendonly $APPENDONLY \
|
2024-10-04 05:52:17 +08:00
|
|
|
--save "$SAVE" \
|
2024-10-10 04:09:08 +08:00
|
|
|
--protected-mode no
|