flpjck/flapjack — pull request #415 by ali-graham (2014-01-13 02:59:46+00:00)
Title: poll for signal changes inside EM loop, fixes reloading behaviour

Per http://www.mikeperham.com/2013/02/23/signal-handling-with-ruby/ it's not really safe to do anything tricky inside signal handlers; they run in the main thread and could 'interrupt' execution of that thread at any time.

I've followed the solution adopted for Sidekiq; although I'm not a fan of polling, it's probably the cleanest way of ensuring that pikelet stopping and reloading definitely happen within the Eventmachine context that has been created.

The proposed Flapjack 2.0 already has a similar structure, but with mutex-locked signals so no polling will be needed. (Reloading is currently disabled in that branch, it's probably the largest missing part at the moment.)