Refactors process ID handling in Rabbit Carrots plugin to use $$ instead of $PROCESS_ID for improved compatibility

This commit is contained in:
Ari Karim 2025-05-25 15:14:30 +03:00
parent cb41e257fc
commit ac06deb86a
No known key found for this signature in database
GPG Key ID: 1A5559E2E32F1805

View File

@ -1,5 +1,4 @@
# rabbit_carrots.rb # rabbit_carrots.rb
require 'English'
require 'puma/plugin' require 'puma/plugin'
require 'rabbit_carrots' require 'rabbit_carrots'
@ -8,7 +7,7 @@ Puma::Plugin.create do
def start(launcher) def start(launcher)
@log_writer = launcher.log_writer @log_writer = launcher.log_writer
@puma_pid = $PROCESS_ID @puma_pid = $$
@core_service = RabbitCarrots::Core.new(logger: log_writer) @core_service = RabbitCarrots::Core.new(logger: log_writer)
@ -58,7 +57,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_ID) Process.kill('TERM', $$)
break break
end end
sleep 2 sleep 2