This repository was archived by the owner on Jul 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 10 files changed +64
-16
lines changed
services-config/supervisor/supervisord.d Expand file tree Collapse file tree 10 files changed +64
-16
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ RUN ln -sf \
4040 && chgrp redis \
4141 /usr/sbin/redis-server-wrapper \
4242 && sed -i -r \
43+ -e "s~^(logfile ).+$~\1\"\" ~" \
4344 -e "s~^(bind ).+$~\1 0.0.0.0~" \
4445 -e "s~^(# *)?(maxmemory ).+$~\2 {{REDIS_MAXMEMORY}}~" \
4546 -e "s~^(# *)?(maxmemory-policy ).+$~\2 {{REDIS_MAXMEMORY_POLICY}}~" \
@@ -59,8 +60,8 @@ ENV REDIS_AUTOSTART_REDIS_BOOTSTRAP="true" \
5960 REDIS_MAXMEMORY_SAMPLES="5" \
6061 REDIS_OPTIONS="" \
6162 REDIS_TCP_BACKLOG="1024" \
62- SSH_AUTOSTART_SSHD=false \
63- SSH_AUTOSTART_SSHD_BOOTSTRAP=false
63+ SSH_AUTOSTART_SSHD=" false" \
64+ SSH_AUTOSTART_SSHD_BOOTSTRAP=" false"
6465
6566# -----------------------------------------------------------------------------
6667# Set image metadata
Original file line number Diff line number Diff line change @@ -66,14 +66,14 @@ $ docker run \
6666 --detach \
6767 --name redis.pool-1.1.1 \
6868 --publish 6379:6379/tcp \
69+ --sysctl "net.core.somaxconn=2048" \
70+ --sysctl "net.ipv4.ip_local_port_range=1024 65535" \
71+ --sysctl "net.ipv4.route.flush=1" \
6972 --env "REDIS_MAXMEMORY=32mb" \
7073 --env "REDIS_MAXMEMORY_POLICY=allkeys-lru" \
7174 --env "REDIS_MAXMEMORY_SAMPLES=10" \
7275 --env "REDIS_OPTIONS=--loglevel verbose" \
7376 --env "REDIS_TCP_BACKLOG=2048" \
74- --sysctl "net.core.somaxconn=2048" \
75- --sysctl "net.ipv4.ip_local_port_range=1024 65535" \
76- --sysctl "net.ipv4.route.flush=1" \
7777 jdeathe/centos-ssh-redis:1.0.0
7878```
7979
Original file line number Diff line number Diff line change 33define DOCKER_CONTAINER_PARAMETERS
44--name $(DOCKER_NAME ) \
55--restart $(DOCKER_RESTART_POLICY ) \
6+ --sysctl "net.core.somaxconn=$(SYSCTL_NET_CORE_SOMAXCONN ) " \
7+ --sysctl "net.ipv4.ip_local_port_range=$(SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE ) " \
8+ --sysctl "net.ipv4.route.flush=$(SYSCTL_NET_IPV4_ROUTE_FLUSH ) " \
69--env "REDIS_AUTOSTART_REDIS_BOOTSTRAP=$(REDIS_AUTOSTART_REDIS_BOOTSTRAP ) " \
710--env "REDIS_AUTOSTART_REDIS_WRAPPER=$(REDIS_AUTOSTART_REDIS_WRAPPER ) " \
811--env "REDIS_MAXMEMORY=$(REDIS_MAXMEMORY ) " \
Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ DOCKER_IMAGE_RELEASE_TAG_PATTERN := ^(1|centos-6-1)\.[0-9]+\.[0-9]+$
1313# Variables
1414# -----------------------------------------------------------------------------
1515
16+ # Docker --sysctl settings
17+ SYSCTL_NET_CORE_SOMAXCONN ?= 1024
18+ SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE ?= 1024 65535
19+ SYSCTL_NET_IPV4_ROUTE_FLUSH ?= 1
20+
1621# Docker image/container settings
1722DOCKER_CONTAINER_OPTS ?=
1823DOCKER_IMAGE_TAG ?= latest
Original file line number Diff line number Diff line change 22priority = 100
33command = /usr/sbin/redis-server-wrapper
44autostart = %(ENV_REDIS_AUTOSTART_REDIS_WRAPPER)s
5- startsecs = 0
5+ startsecs = 1
66autorestart = true
77redirect_stderr = true
8- stdout_logfile = /var/log/redis-server-wrapper
8+ stdout_logfile = /var/log/redis/redis.log
99stdout_events_enabled = true
1010user = redis
Original file line number Diff line number Diff line change @@ -59,9 +59,12 @@ Environment="REDIS_AUTOSTART_REDIS_BOOTSTRAP=true"
5959Environment ="REDIS_AUTOSTART_REDIS_WRAPPER=true"
6060Environment ="REDIS_MAXMEMORY=64mb"
6161Environment ="REDIS_MAXMEMORY_POLICY=allkeys-lru"
62- Environment ="REDIS_MAXMEMORY_SAMPLES=10 "
62+ Environment ="REDIS_MAXMEMORY_SAMPLES=5 "
6363Environment ="REDIS_OPTIONS="
6464Environment ="REDIS_TCP_BACKLOG=1024"
65+ Environment ="SYSCTL_NET_CORE_SOMAXCONN=1024"
66+ Environment ="SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE=1024 65535"
67+ Environment ="SYSCTL_NET_IPV4_ROUTE_FLUSH=1"
6568
6669# Initialisation: Load image from local storage if available, otherwise pull.
6770ExecStartPre =/bin/bash -c \
@@ -91,6 +94,9 @@ ExecStartPre=-/bin/bash -c \
9194ExecStart =/bin/bash -c \
9295 "exec /usr/bin/docker run \
9396 --name %p.%i \
97+ --sysctl \" net.core.somaxconn =${SYSCTL_NET_CORE_SOMAXCONN}\" \
98+ --sysctl \" net.ipv4.ip_local_port_range =${SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE}\" \
99+ --sysctl \" net.ipv4.route.flush =${SYSCTL_NET_IPV4_ROUTE_FLUSH}\" \
94100 --env \" REDIS_AUTOSTART_REDIS_BOOTSTRAP =${REDIS_AUTOSTART_REDIS_BOOTSTRAP}\" \
95101 --env \" REDIS_AUTOSTART_REDIS_WRAPPER =${REDIS_AUTOSTART_REDIS_WRAPPER}\" \
96102 --env \" REDIS_MAXMEMORY =${REDIS_MAXMEMORY}\" \
Original file line number Diff line number Diff line change 4040# Common parameters of create and run targets
4141DOCKER_CONTAINER_PARAMETERS=" --name ${DOCKER_NAME} \
4242--restart ${DOCKER_RESTART_POLICY} \
43+ --sysctl \" net.core.somaxconn=${SYSCTL_NET_CORE_SOMAXCONN} \" \
44+ --sysctl \" net.ipv4.ip_local_port_range=${SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE} \" \
45+ --sysctl \" net.ipv4.route.flush=${SYSCTL_NET_IPV4_ROUTE_FLUSH} \" \
4346--env \" REDIS_AUTOSTART_REDIS_BOOTSTRAP=${REDIS_AUTOSTART_REDIS_BOOTSTRAP} \" \
4447--env \" REDIS_AUTOSTART_REDIS_WRAPPER=${REDIS_AUTOSTART_REDIS_WRAPPER} \" \
4548--env \" REDIS_MAXMEMORY=${REDIS_MAXMEMORY} \" \
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ DIST_PATH="${DIST_PATH:-./dist}"
3030# Number of seconds expected to complete container startup including bootstrap.
3131STARTUP_TIME=" ${STARTUP_TIME:- 1} "
3232
33+ # Docker --sysctl settings
34+ SYSCTL_NET_CORE_SOMAXCONN=" ${SYSCTL_NET_CORE_SOMAXCONN:- 1024} "
35+ SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE=" ${SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE:- 1024 65535} "
36+ SYSCTL_NET_IPV4_ROUTE_FLUSH=" ${SYSCTL_NET_IPV4_ROUTE_FLUSH:- 1} "
37+
3338# ETCD register service settings
3439REGISTER_ETCD_PARAMETERS=" ${REGISTER_ETCD_PARAMETERS:- } "
3540REGISTER_TTL=" ${REGISTER_TTL:- 60} "
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ readonly SERVICE_UNIT_ENVIRONMENT_KEYS="
1414 REDIS_MAXMEMORY_SAMPLES
1515 REDIS_OPTIONS
1616 REDIS_TCP_BACKLOG
17+ SYSCTL_NET_CORE_SOMAXCONN
18+ SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE
19+ SYSCTL_NET_IPV4_ROUTE_FLUSH
1720"
1821readonly SERVICE_UNIT_REGISTER_ENVIRONMENT_KEYS="
1922 REGISTER_ETCD_PARAMETERS
Original file line number Diff line number Diff line change 44
55readonly CONFIG_PATH=" /etc/redis.conf"
66readonly LOCK_FILE=" /var/lock/subsys/redis-server-bootstrap"
7+ readonly LOG_FILE=" /var/log/redis/redis.log"
78readonly OPTIONS=" ${REDIS_OPTIONS:- } "
89readonly TIMER_START=" $(
910 date +%s.%N
@@ -32,29 +33,50 @@ function load_config ()
3233 fi
3334}
3435
36+ function set_log_write_user ()
37+ {
38+ local file_path=" ${1:- } "
39+ local user=" ${2:- } "
40+
41+ if [[ ! -f ${file_path} ]]
42+ then
43+ touch \
44+ " ${file_path} "
45+ fi
46+
47+ chown \
48+ " ${user} " :" ${user} " \
49+ " ${file_path} "
50+
51+ chmod \
52+ 0660 \
53+ " ${file_path} "
54+ }
55+
3556function set_wrapper_execute_user ()
3657{
3758 local file_path=" ${1:- } "
3859 local user=" ${2:- } "
3960
4061 chgrp \
41- " ${USER } " \
42- " ${WRAPPER } "
62+ " ${user } " \
63+ " ${file_path } "
4364
4465 chmod \
4566 0750 \
46- " ${WRAPPER } "
67+ " ${file_path } "
4768}
4869
49- load_config \
50- " ${CONFIG_PATH} "
51-
5270set_wrapper_execute_user \
5371 " ${WRAPPER} " \
5472 " ${USER} "
5573
56- # Force a longer execution time to allow output in logs
57- sleep 0.05
74+ set_log_write_user \
75+ " ${LOG_FILE} " \
76+ " ${USER} "
77+
78+ load_config \
79+ " ${CONFIG_PATH} "
5880
5981TIMER_TOTAL=" $(
6082 echo - | awk " \
You can’t perform that action at this time.
0 commit comments