Skip to content

Commit

Permalink
Configure log for media listener
Browse files Browse the repository at this point in the history
  • Loading branch information
aidewoode committed Dec 21, 2023
1 parent 689f06f commit 314f881
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Expand Up @@ -5,7 +5,7 @@ FROM base AS builder
ENV RAILS_ENV production
ENV NODE_ENV production

# build for musl-libc, not glibc (see https://github.com/sparklemotion/nokogiri/issues/2075, https://github.com/rubygems/rubygems/issues/3174)
# Build for musl-libc, not glibc (see https://github.com/sparklemotion/nokogiri/issues/2075, https://github.com/rubygems/rubygems/issues/3174)
ENV BUNDLE_FORCE_RUBY_PLATFORM 1

COPY --from=node /usr/local/bin/node /usr/local/bin/node
Expand Down Expand Up @@ -56,6 +56,9 @@ RUN addgroup -g 1000 -S app && adduser -u 1000 -S app -G app
COPY --from=builder --chown=app:app /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder --chown=app:app /app/ /app/

# Forwards media listener logs to stdout so they can be captured in docker logs.
RUN ln -sf /dev/stdout /app/log/media_listener_production.log

USER app

ENTRYPOINT ["docker/entrypoint.sh"]
Expand Down
8 changes: 7 additions & 1 deletion lib/daemons/media_listener_service
Expand Up @@ -25,14 +25,20 @@ daemon_options = {
dir_mode: :normal,
dir: options[:dir],
multiple: false,
shush: ENV["RAILS_ENV"] == "test"
shush: ENV["RAILS_ENV"] == "test",
log_output: true,
log_dir: File.join(ROOT_DIR, "log"),
output_logfilename: "media_listener_#{ENV["RAILS_ENV"]}.log"
}

Daemons.run_proc(options[:name], daemon_options) do
Dir.chdir ROOT_DIR

require "./config/environment"

listener_log_level = (ENV["RAILS_ENV"] == "production") ? :info : :debug
Listen.logger = ::Logger.new($stdout, level: ENV.fetch("RAILS_LOG_LEVEL", listener_log_level))

supported_formates = MediaFile::SUPPORTED_FORMATS.map { |formate| %r{\.#{formate}$} }

listener = Listen.to(File.expand_path(Setting.media_path), only: supported_formates, latency: 5, wait_for_delay: 10) do |modified, added, removed|
Expand Down

0 comments on commit 314f881

Please sign in to comment.