From e951dac5068b0aa2d7c669b7c15d6af1b7c5f35f Mon Sep 17 00:00:00 2001 From: icyleaf Date: Mon, 8 Apr 2024 11:22:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=20redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup | 9 +-------- config.env | 3 --- scripts/check-requirements.sh | 2 +- scripts/configure-volumes.sh | 5 +---- scripts/wrap-up.sh | 5 +---- 5 files changed, 4 insertions(+), 20 deletions(-) diff --git a/backup b/backup index 2509d7a..85ca7ab 100755 --- a/backup +++ b/backup @@ -22,12 +22,6 @@ backup_db () { docker cp zealot-postgresql:/tmp/db.dump $BACKUP_DIR } -backup_redis () { - echo "" - echo "== Backup redis ==" - docker cp zealot-redis:/data/dump.rdb $BACKUP_DIR/redis.rdb -} - backup_zealot () { echo "" echo "== Backup zealot data ==" @@ -43,12 +37,11 @@ compress () { cleanup () { echo echo "== Cleaning up ==" - rm -rf $BACKUP_DIR/uploads $BACKUP_DIR/db.dump $BACKUP_DIR/redis.rdb + rm -rf $BACKUP_DIR/uploads $BACKUP_DIR/db.dump } trap cleanup ERR INT TERM HUP QUIT backup_db -backup_redis backup_zealot compress cleanup diff --git a/config.env b/config.env index 1493407..04cfc69 100644 --- a/config.env +++ b/config.env @@ -123,6 +123,3 @@ ZEALOT_POSTGRES_PORT=5432 ZEALOT_POSTGRES_USERNAME=postgres ZEALOT_POSTGRES_PASSWORD=ze@l0t ZEALOT_POSTGRES_DB_NAME=zealot - -# The full Redis URL for the Redis cache. -REDIS_URL=redis://redis:6379/0 diff --git a/scripts/check-requirements.sh b/scripts/check-requirements.sh index e217c78..71817d4 100755 --- a/scripts/check-requirements.sh +++ b/scripts/check-requirements.sh @@ -11,7 +11,7 @@ function ver () { echo "$@" | awk -F. '{ printf("%d%03d%03d", $1,$2,$3); }'; } ## Check docker compose version (v1 and v2) ## function get_docker_compose_version () { - COMPOSE_VERSION=$(docker-compose version | head -n1 | sed -E 's/^.* version:? v?([0-9.]+),?.*$/\1/') + COMPOSE_VERSION=$(dc_base version | head -n1 | sed -E 's/^.* version:? v?([0-9.]+),?.*$/\1/') } ## diff --git a/scripts/configure-volumes.sh b/scripts/configure-volumes.sh index fb94b5d..c72c62e 100755 --- a/scripts/configure-volumes.sh +++ b/scripts/configure-volumes.sh @@ -13,7 +13,6 @@ create_docker_volumes () { echo "Created $(docker volume create --name=zealot-uploads)." echo "Created $(docker volume create --name=zealot-backup)." echo "Created $(docker volume create --name=zealot-postgres)." - echo "Created $(docker volume create --name=zealot-redis)." cat $TEMPLATE_DOCKER_COMPOSE_PATH/external-volumes.yml >> $DOCKER_COMPOSE_FILE echo "Exteral volumes write to file: $DOCKER_COMPOSE_FILE" @@ -30,12 +29,10 @@ configure_local_docker_volumes() { else mkdir -p "$stored/zealot/uploads" mkdir -p "$stored/zealot/backup" - mkdir -p "$stored/redis" mkdir -p "$stored/postgres" sed -i -e 's|zealot-uploads|'"$stored"'/uploads|g' $DOCKER_COMPOSE_FILE sed -i -e 's|zealot-backup|'"$stored"'/backup|g' $DOCKER_COMPOSE_FILE - sed -i -e 's|zealot-redis|'"$stored"'/redis|g' $DOCKER_COMPOSE_FILE sed -i -e 's|zealot-postgres|'"$stored"'/postgres|g' $DOCKER_COMPOSE_FILE clean_sed_temp_file $DOCKER_COMPOSE_FILE @@ -67,7 +64,7 @@ choose_volumes () { VOLUMES_EXISTS=$(grep -qcE "^(\s+)zealot\-(\w+):" $DOCKER_COMPOSE_FILE || echo 0) -if [ "$VOLUMES_EXISTS" -eq 4 ]; then +if [ "$VOLUMES_EXISTS" -eq 3 ]; then echo "Volumes already exists, skipped" else choose_volumes diff --git a/scripts/wrap-up.sh b/scripts/wrap-up.sh index ca382fe..71bac99 100755 --- a/scripts/wrap-up.sh +++ b/scripts/wrap-up.sh @@ -5,9 +5,6 @@ if [[ "$MINIMIZE_DOWNTIME" ]]; then $dc up -d --remove-orphans $($dc config --services | grep -v -E '^(web)$') $dc exec -T web caddy reload --config /etc/caddy/Caddyfile - docker run --rm --network="${COMPOSE_PROJECT_NAME}_default" redis:5-alpine ash \ - -c 'while [[ "$(wget -T 1 -q -O- http://web:3000/_health/)" != "ok" ]]; do sleep 0.5; done' - # Make sure everything is up. This should only touch relay and nginx $dc up -d @@ -18,7 +15,7 @@ else echo "" echo "You're all done! Run the following command to get Zealot running:" echo "" - echo " [sudo] docker-compose up -d" + echo " [sudo] docker compose up -d" echo "" echo "-----------------------------------------------------------------" echo ""