From 6650b705c42b996594f223297af2613079ed2d73 Mon Sep 17 00:00:00 2001 From: sadnub Date: Sun, 6 Jun 2021 22:54:52 -0400 Subject: [PATCH] configure redis to use an appendonly file for celery task reliability --- .devcontainer/docker-compose.yml | 4 ++++ backup.sh | 5 ++++- docker/docker-compose.yml | 4 ++++ install.sh | 6 +++++- restore.sh | 6 +++++- update.sh | 6 +++++- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 84199f44..25988f9b 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -115,7 +115,10 @@ services: redis-dev: container_name: trmm-redis-dev restart: always + command: redis-server --appendonly yes image: redis:6.0-alpine + volumes: + - redis-data-dev:/data networks: dev: aliases: @@ -247,6 +250,7 @@ volumes: postgres-data-dev: mongo-dev-data: mesh-data-dev: + redis-data-dev: networks: dev: diff --git a/backup.sh b/backup.sh index 07ec4605..97d3e80f 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="12" +SCRIPT_VERSION="13" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/backup.sh' GREEN='\033[0;32m' @@ -59,6 +59,7 @@ mkdir ${tmp_dir}/nginx mkdir ${tmp_dir}/systemd mkdir ${tmp_dir}/rmm mkdir ${tmp_dir}/confd +mkdir ${tmp_dir}/redis pg_dump --dbname=postgresql://"${POSTGRES_USER}":"${POSTGRES_PW}"@127.0.0.1:5432/tacticalrmm | gzip -9 > ${tmp_dir}/postgres/db-${dt_now}.psql.gz @@ -72,6 +73,8 @@ sudo tar -czvf ${tmp_dir}/nginx/etc-nginx.tar.gz -C /etc/nginx . sudo tar -czvf ${tmp_dir}/confd/etc-confd.tar.gz -C /etc/conf.d . +sudo tar -czvf ${tmp_dir}/redis/etc-redis.tar.gz -C /var/lib/redis/appendonly.aof + sudo cp ${sysd}/rmm.service ${sysd}/celery.service ${sysd}/celerybeat.service ${sysd}/meshcentral.service ${sysd}/nats.service ${tmp_dir}/systemd/ if [ -f "${sysd}/daphne.service" ]; then sudo cp ${sysd}/daphne.service ${tmp_dir}/systemd/ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index c2b2fb06..d32a33f3 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -18,6 +18,7 @@ volumes: postgres_data: mongo_data: mesh_data: + redis_data: services: # postgres database for api service @@ -38,7 +39,10 @@ services: tactical-redis: container_name: trmm-redis image: redis:6.0-alpine + command: redis-server --appendonly yes restart: always + volumes: + - redis_data:/data networks: - redis diff --git a/install.sh b/install.sh index cb1c4395..e92397b5 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="49" +SCRIPT_VERSION="50" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/install.sh' sudo apt install -y curl wget dirmngr gnupg lsb-release @@ -217,6 +217,10 @@ sudo rm -rf Python-3.9.2 Python-3.9.2.tgz print_green 'Installing redis and git' sudo apt install -y ca-certificates redis git +# apply redis configuration +sudo redis-cli config set appendonly yes +sudo redis-cli config rewrite + print_green 'Installing postgresql' echo "$postgresql_repo" | sudo tee /etc/apt/sources.list.d/pgdg.list diff --git a/restore.sh b/restore.sh index e2459da0..52fa08e3 100755 --- a/restore.sh +++ b/restore.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="27" +SCRIPT_VERSION="28" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/restore.sh' sudo apt update @@ -189,6 +189,10 @@ sudo rm -rf Python-3.9.2 Python-3.9.2.tgz print_green 'Installing redis and git' sudo apt install -y ca-certificates redis git +# redis configuration +sudo tar -xzf ${tmp_dir}/redis/etc-redis.tar.gz -C /var/lib/redis +sudo redis-check-aof --fix /var/lib/redis/appendonly.aof + print_green 'Installing postgresql' echo "$postgresql_repo" | sudo tee /etc/apt/sources.list.d/pgdg.list diff --git a/update.sh b/update.sh index f885eab8..76a9809b 100644 --- a/update.sh +++ b/update.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="122" +SCRIPT_VERSION="123" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/update.sh' LATEST_SETTINGS_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py' YELLOW='\033[1;33m' @@ -307,5 +307,9 @@ if [[ "${CURRENT_MESH_VER}" != "${LATEST_MESH_VER}" ]] || [[ "$force" = true ]]; sudo systemctl start meshcentral fi +# apply redis configuration +sudo redis-cli config set appendonly yes +sudo redis-cli config rewrite + rm -f $TMP_SETTINGS printf >&2 "${GREEN}Update finished!${NC}\n" \ No newline at end of file