From 866b10ceca7986434015b7d7533be1b69e9ceeac Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Wed, 11 Dec 2024 14:34:59 +0100 Subject: [PATCH] Change mapping for redis container and add logs to export process --- CHANGELOG.md | 19 +++++++++++++++++++ app/services/exports/create.rb | 12 +++++++++--- docker-compose.yml | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d8e836..355cd0e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,15 +7,34 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # 0.19.6 - 2024-12-11 +⚠️ This release introduces a breaking change. ⚠️ + +The `dawarich_shared` volume now being mounted to `/data` instead of `/var/shared` within the container. It fixes Redis data being lost on container restart. + +To change this, you need to update the `docker-compose.yml` file: + +```diff + dawarich_redis: + image: redis:7.0-alpine + container_name: dawarich_redis + command: redis-server + volumes: ++ - dawarich_shared:/data + restart: always + healthcheck: +``` + ### Fixed - Flash messages are now being removed after 5 seconds. - Fixed broken migration that was preventing the app from starting. - Visits page is now loading a lot faster than before. +- Redis data should now be preserved on container restart. ### Changed - Places page is now accessible from the Visits & Places tab on the navbar. +- Exporting process is now being logged. # 0.19.5 - 2024-12-10 diff --git a/app/services/exports/create.rb b/app/services/exports/create.rb index 2d31a9c0..08181b4d 100644 --- a/app/services/exports/create.rb +++ b/app/services/exports/create.rb @@ -18,7 +18,7 @@ class Exports::Create create_export_file(data) - export.update!(status: :completed, url: "exports/#{export.name}.#{file_format}") + export.update!(status: :completed, url: "exports/#{export.name}") create_export_finished_notification rescue StandardError => e @@ -74,10 +74,16 @@ class Exports::Create def create_export_file(data) dir_path = Rails.root.join('public/exports') - Dir.mkdir(dir_path) unless Dir.exist?(dir_path) - file_path = dir_path.join("#{export.name}.#{file_format}") + FileUtils.mkdir_p(dir_path) unless Dir.exist?(dir_path) + + file_path = dir_path.join(export.name) + + Rails.logger.info("Creating export file at: #{file_path}") File.open(file_path, 'w') { |file| file.write(data) } + rescue StandardError => e + Rails.logger.error("Failed to create export file: #{e.message}") + raise end end diff --git a/docker-compose.yml b/docker-compose.yml index c04194f0..cf8dbf62 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: networks: - dawarich volumes: - - dawarich_shared:/var/shared/redis + - dawarich_shared:/data restart: always healthcheck: test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]