Skip to content

Commit

Permalink
Fixes #35774 - don't fail if #{Rails.root}/tmp is not available (#10362)
Browse files Browse the repository at this point in the history
This can happen in rake tasks, so let's:
1. not initialize EventDaemon in rake at all -- it won't run anyway
2. ensure the `tmp` directory is properly created before use
  • Loading branch information
evgeni committed Dec 6, 2022
1 parent b31ae26 commit 16d25a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/lib/katello/event_daemon/runner.rb
Expand Up @@ -7,6 +7,7 @@ class Runner

class << self
def initialize
FileUtils.mkdir_p(tmp_dir)
FileUtils.touch(lock_file)
end

Expand All @@ -24,12 +25,16 @@ def pid_file
pid_dir.join('katello_event_daemon.pid')
end

def tmp_dir
Rails.root.join('tmp')
end

def pid_dir
Rails.root.join('tmp', 'pids')
tmp_dir.join('pids')
end

def lock_file
Rails.root.join('tmp', 'katello_event_daemon.lock')
tmp_dir.join('katello_event_daemon.lock')
end

def write_pid_file
Expand Down
2 changes: 1 addition & 1 deletion lib/katello/engine.rb
Expand Up @@ -146,7 +146,7 @@ class Engine < ::Rails::Engine
)
end

Katello::EventDaemon::Runner.initialize
Katello::EventDaemon::Runner.initialize unless Foreman.in_rake?
Katello::EventDaemon::Runner.register_service(:candlepin_events, Katello::CandlepinEventListener)
Katello::EventDaemon::Runner.register_service(:katello_events, Katello::EventMonitor::PollerThread)
Katello::EventDaemon::Runner.register_service(:katello_agent_events, Katello::EventDaemon::Services::AgentEventReceiver) if ::Katello.with_katello_agent?
Expand Down

0 comments on commit 16d25a5

Please sign in to comment.