From 837ca8f1f344528add7060101d1e8c4cd575d2a9 Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Sun, 19 Feb 2017 15:55:27 -0700 Subject: [PATCH] Fix api-umbrella process stop sometimes taking a long time. --- .../web-app/config/initializers/delayed_job.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api-umbrella/web-app/config/initializers/delayed_job.rb b/src/api-umbrella/web-app/config/initializers/delayed_job.rb index cae8a5f3f..07bf06989 100644 --- a/src/api-umbrella/web-app/config/initializers/delayed_job.rb +++ b/src/api-umbrella/web-app/config/initializers/delayed_job.rb @@ -1,3 +1,13 @@ +# Exit immediately when the delayed_job process receives a kill signal. +# +# This prevents some race conditions that can lead to API Umbrella stopping +# taking a long time. If mongo is running on the same server and mongo exits +# first, then without exiting immediately, delayed_job can get stuck waiting +# for a new mongo primary (until the 30s server_selection_timeout is hit) +# before exiting. +Delayed::Worker.raise_signal_exceptions = true + +# Keep failed jobs in the database. Delayed::Worker.destroy_failed_jobs = false if(Rails.env.test?)