diff --git a/Gemfile b/Gemfile index d1e7c8f..2f814e9 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,7 @@ gem 'omniauth-rails_csrf_protection', '~> 1.0' gem 'pg', '~> 1.4' gem 'pg_search', '~> 2.3' gem 'puma', '~> 7.2' +gem 'puma-plugin-delayed_stop', '~> 0.1.2' gem 'rack-cors' gem 'rails', '~> 8.0.5' gem 'ransack', '~> 4.2' diff --git a/Gemfile.lock b/Gemfile.lock index a8ac3b3..8ad3965 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -253,6 +253,8 @@ GEM public_suffix (7.0.5) puma (7.2.0) nio4r (~> 2.0) + puma-plugin-delayed_stop (0.1.2) + puma (>= 5.0, < 8) racc (1.8.1) rack (3.2.5) rack-cors (2.0.2) @@ -442,6 +444,7 @@ DEPENDENCIES pg (~> 1.4) pg_search (~> 2.3) puma (~> 7.2) + puma-plugin-delayed_stop (~> 0.1.2) rack-cors rails (~> 8.0.5) rails-controller-testing diff --git a/config/puma.rb b/config/puma.rb index 0593712..1532bcf 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -41,3 +41,6 @@ # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart + +# Adds a drain period during shutdown so swarm can elegantly remove it from the routing mesh +plugin :delayed_stop diff --git a/docker-compose.yml b/docker-compose.yml index 1b68ba9..d805e19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: environment: - SERVE_TEST_UI=${SERVE_TEST_UI:-true} - GALC_API_URL=${GALC_API_URL:-http://localhost:3000} + - PUMA_DELAYED_STOP_DRAIN_SECONDS=1 init: true networks: default: @@ -19,6 +20,8 @@ services: ports: - 3000:3000 restart: always + stop_grace_period: 30s + stop_signal: SIGQUIT db: environment: @@ -38,5 +41,3 @@ services: volumes: postgres_data: { } - -version: '3.8'