Added log rotation for prod config (#32)

This commit is contained in:
Kieran
2024-02-21 12:01:18 -08:00
committed by GitHub
parent c1f30dbd2c
commit 0d29f70a28
3 changed files with 20 additions and 3 deletions
+17
View File
@@ -29,6 +29,8 @@ if config_env() == :prod do
For example: /etc/pinchflat/pinchflat.db For example: /etc/pinchflat/pinchflat.db
""" """
log_path = System.get_env("LOG_PATH", "log/pinchflat.log")
config :pinchflat, yt_dlp_executable: System.find_executable("yt-dlp") config :pinchflat, yt_dlp_executable: System.find_executable("yt-dlp")
config :pinchflat, Pinchflat.Repo, config :pinchflat, Pinchflat.Repo,
@@ -74,6 +76,21 @@ if config_env() == :prod do
], ],
secret_key_base: secret_key_base secret_key_base: secret_key_base
config :pinchflat, :logger, [
{:handler, :file_log, :logger_std_h,
%{
config: %{
type: :file,
file: String.to_charlist(log_path),
filesync_repeat_interval: 5000,
file_check: 5000,
max_no_files: 5,
max_no_bytes: 10_000_000
},
formatter: Logger.Formatter.new()
}}
]
# ## SSL Support # ## SSL Support
# #
# To get SSL working, you will need to add the `https` key # To get SSL working, you will need to add the `https` key
+1
View File
@@ -22,6 +22,7 @@ defmodule Pinchflat.Application do
] ]
:ok = Oban.Telemetry.attach_default_logger() :ok = Oban.Telemetry.attach_default_logger()
Logger.add_handlers(:pinchflat)
# See https://hexdocs.pm/elixir/Supervisor.html # See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options # for other strategies and supported options
+2 -3
View File
@@ -96,12 +96,11 @@ RUN chown nobody /app
# Set up data volumes # Set up data volumes
RUN mkdir /config /downloads RUN mkdir /config /downloads
RUN chown nobody /config /downloads RUN chown nobody /config /downloads
VOLUME /config
VOLUME /downloads
# set runner ENV # set runner ENV
ENV MIX_ENV="prod" ENV MIX_ENV="prod"
ENV DATABASE_PATH="/config/pinchflat.db" ENV DATABASE_PATH="/config/db/pinchflat.db"
ENV LOG_PATH="/config/logs/pinchflat.log"
ENV PORT=8945 ENV PORT=8945
ENV RUN_CONTEXT="selfhosted" ENV RUN_CONTEXT="selfhosted"