fix unlocking of jobs upon receiving SIGTERM
fix unlocking of jobs upon receiving SIGTERM

Before this change, we were relying on hitting the `ensure`
block to unlock jobs associated with the exiting worker:

Delayed::Job.clear_locks!(name)

In other words, the default expected behavior is that when
a worker exits, it unlocks its own jobs.

After adding some logging, I found that there are cases when
workers can take a while to exit the run loop and get to the
ensure block. In the context of a SIGTERM, we need to run cleanup
as soon as possible, since a SIGKILL is right around the corner.
In my testing, I saw that 1 or 2 worker threads consistently never
hit the ensure block before receiving a SIGKILL.

The signal_processor thread is working as expected and captures
signals as soon as they are sent to the process. We should run
the cleanup code as soon as possible after receiving the first
termination signal, which is the goal of this change.

Change-Id: If6f6252a8a05ad3bb54879d593f9fa8dead77750
Reviewed-on: https://gerrit.instructure.com/202737
Tested-by: Jenkins
Reviewed-by: Ben Rinaca <55a6093a45d41fed7a0fcf1e8dbdc41f5092bc04@instructure.com>
Reviewed-by: Tyler Pickett <3f20fcf21b1970c94966160adcf831eedd808a06@instructure.com>

instructure/inst-jobs,instructure/canvas-jobs,instructure/inst-jobs,instructure/canvas-jobs,instructure/canvas-jobs,instructure/inst-jobs,instructure/inst-jobs,instructure/canvas-jobs