I would like to automatically launch a background thread at the start of my rails app and terminate it at stop (Ctrl + C in dev mode or kill signal in production)
I've no problem launching my thread at start, but I can't manage to terminate it at stop. Either it doesn't stop, either it prevent my rails app from quitting.
Is there an automatic way ? Or should I hook the rails stop ? How ?
Thanks in advance for your advices.
P.S. By the way, do you know how to use the "pid" feature of the rails thread ? I mean the way to put a small text file in tmp/pids at start and removing it automatically. I'm sure there are some functions to do that.