envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Wake up sleeping main thread upon receiving a signal #207

Closed orien closed 6 years ago

orien commented 6 years ago

Context

We have a custom event source with a long polling interval (5 minutes). This plays havoc with the Event Sourcery graceful shutdown mechanism as it will take up to 5 minutes to stop.

We set @shutdown_requested upon receiving SIGTERM. But we only check @shutdown_request after waking from the poll wait sleep.

Change

Instruct the main thread to wake upon receiving SIGTERM or SIGINT. So we don't wait the remainder of the poll wait sleep.