From 221fab47c6b009f1d939bc59517c4dac669c1698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20A=2E=20Matienzo?= Date: Thu, 26 Mar 2026 10:42:05 -0700 Subject: [PATCH] AP-621: implement puma-plugin-delayed_stop --- Gemfile | 1 + Gemfile.lock | 3 +++ config/puma.rb | 3 +++ docker-compose.yml | 3 +++ 4 files changed, 10 insertions(+) diff --git a/Gemfile b/Gemfile index 0437063..7a1f184 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem 'nokogiri', '~> 1.18' gem 'okcomputer', '~> 1.19' gem 'ougai', '~> 1.8' gem 'puma', '~> 6.6.1' +gem 'puma-plugin-delayed_stop', '~> 0.1.2' gem 'rails', '~> 8.0.0' gem 'rake' gem 'sass-rails', '>= 6' diff --git a/Gemfile.lock b/Gemfile.lock index 99fc440..4fb27e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,6 +212,8 @@ GEM public_suffix (7.0.0) puma (6.6.1) nio4r (~> 2.0) + puma-plugin-delayed_stop (0.1.2) + puma (>= 5.0, < 8) racc (1.8.1) rack (3.2.4) rack-proxy (0.7.7) @@ -410,6 +412,7 @@ DEPENDENCIES okcomputer (~> 1.19) ougai (~> 1.8) puma (~> 6.6.1) + puma-plugin-delayed_stop (~> 0.1.2) rails (~> 8.0.0) rake rspec-rails (~> 8.0) diff --git a/config/puma.rb b/config/puma.rb index a248513..3037022 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -36,6 +36,9 @@ # Run the Solid Queue supervisor inside of Puma for single-server deployments plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] +# enable the delayed_stop plugin to intercept signals +plugin :delayed_stop + # Specify the PID file. Defaults to tmp/pids/server.pid in development. # In other environments, only set the PID file if requested. pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/docker-compose.yml b/docker-compose.yml index 8ebeaae..22e9ec8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,8 +21,11 @@ services: - db environment: DATABASE_URL: 'mysql2://root:root@db:3306/NARA' + PUMA_DELAYED_STOP_DRAIN_SECONDS: 1 ports: - 3000:3000 restart: always + stop_grace_period: 30s + stop_signal: SIGQUIT volumes: - ./:/opt/app:delegated