beanstalkd / beaneater

The best way to interact with beanstalkd from within Ruby
http://beanstalkd.github.com/beaneater
MIT License
199 stars 43 forks source link

Automated processing and signal handling #50

Open martint17r opened 10 years ago

martint17r commented 10 years ago

I wrote a small script to multiplex a tube into multiple other tubes: https://github.com/martint17r/beanstalk-multiplex

I would like to harden it against data loss, i.e. when the script gets interrupted, it should still process the current job and only after finishing it, exit the processing loop and close the connection to the beanstalkd. If there is no job being processed it would be best to close the connection and immediately exit.

I tried using trap(...) but it requires some jumping through burning hoops to bring the signal into the processing loop.

What is the best way to achieve proper signal handling?