#!/bin/sh # Starts the bundled Redis unless an external one is named, then the command. # # Redis holds the last value of every message, node state and the work queue, # so without it a restart forgets all three. In the background on purpose: its # appendonly file is written on every change, so the SIGKILL it gets when the # container stops loses nothing that was acknowledged. # # Its memory-overcommit warning is dropped: the setting is the host kernel's, # nothing in a container can change it, and it only matters to a fork for a # snapshot under memory pressure. Every other warning still reaches the log. set -e if [ -z "$REDIS_HOST" ]; then mkdir -p /data/redis redis-server --bind 127.0.0.1 --port 6379 --dir /data/redis \ --appendonly yes --loglevel warning \ | grep --line-buffered -v "Memory overcommit must be enabled" & i=0 until redis-cli -h 127.0.0.1 ping >/dev/null 2>&1; do i=$((i + 1)) [ "$i" -lt 100 ] || { echo "bundled redis did not start" >&2; exit 1; } sleep 0.1 done export REDIS_HOST=127.0.0.1 fi exec "$@"