Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/cloud_controller/runners/puma_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def initialize(config, app, logger, periodic_updater, request_logs)
prometheus_updater.update_gauge_metric(:cc_db_connection_pool_timeouts_total, 0, labels: { process_type: 'main' })
@periodic_updater.setup_updates
end

events.after_stopped do
@periodic_updater.stop_updates unless @periodic_updater.nil?
stop_periodic_updates
end

@puma_launcher = Puma::Launcher.new(puma_config, log_writer:, events:)
Expand All @@ -78,6 +79,18 @@ def start!

private

def stop_periodic_updates
@periodic_updater&.stop_updates
@logger.info('Successfully stopped periodic updates in after_stopped')
rescue ThreadError
at_exit do
@periodic_updater&.stop_updates
@logger.info('Successfully stopped periodic updates in at_exit')
end
rescue StandardError => e
@logger.error("Failed to stop periodic updates: #{e}\n#{e.backtrace&.join("\n")}")
end

def prometheus_updater
CloudController::DependencyLocator.instance.prometheus_updater
end
Expand Down