Refactors process ID handling in Rabbit Carrots plugin and enhances logging for shutdown scenarios

This commit is contained in:
Ari Karim 2025-05-25 10:56:35 +03:00
parent f68ab83afc
commit aee5a1e3cb
No known key found for this signature in database
GPG Key ID: 1A5559E2E32F1805
2 changed files with 5 additions and 4 deletions

View File

@ -8,7 +8,7 @@ Puma::Plugin.create do
def start(launcher) def start(launcher)
@log_writer = launcher.log_writer @log_writer = launcher.log_writer
@puma_pid = $$ @puma_pid = $PROCESS_ID
@core_service = RabbitCarrots::Core.new(logger: log_writer) @core_service = RabbitCarrots::Core.new(logger: log_writer)
@ -43,6 +43,7 @@ Puma::Plugin.create do
Process.kill('TERM', rabbit_carrots_pid) Process.kill('TERM', rabbit_carrots_pid)
Process.wait(rabbit_carrots_pid) Process.wait(rabbit_carrots_pid)
rescue Errno::ECHILD, Errno::ESRCH rescue Errno::ECHILD, Errno::ESRCH
log 'Rabbit Carrots already stopped'
end end
def monitor_puma def monitor_puma
@ -57,7 +58,7 @@ Puma::Plugin.create do
loop do loop do
if send(process_dead) if send(process_dead)
log message log message
Process.kill('TERM', $$) Process.kill('TERM', $PROCESS_ID)
break break
end end
sleep 2 sleep 2

View File

@ -18,8 +18,8 @@ module RabbitCarrots
:rabbitmq_exchange_name, :rabbitmq_exchange_name,
:automatically_recover, :automatically_recover,
:network_recovery_interval, :network_recovery_interval,
:recovery_attempts, :recovery_attempts
:orm
def orm def orm
@orm ||= :activerecord @orm ||= :activerecord
end end