DataDog / dogstatsd-ruby

A Ruby client for DogStatsd
https://www.datadoghq.com/
MIT License
179 stars 137 forks source link

Is it safe after fork() or not? #253

Closed pudiva closed 2 years ago

pudiva commented 2 years ago

Hiiii dogstaters! 🐩📈

I was reading your README's 5.x pitfalls section about fork() and got confused.

The bullet point says that the sender thread is re-created after fork(), which seems to be correct according to my tests, and also 14c76e3d30d1f36ae364350ab4c52c743be1c0ab.

However, below it, there is a paragraph saying that, if I'm using Unicorn (which I am), then I should instantiate dogstats on the workers, not on the master process ~ that is, instantiate dogstats only after fork(), not before!

There is even a link to a comment from another user who instantiated dogstats on the master process, before the fork(), and had problems because the child processes didn't have the sender thread running...

So what is the current behaviour of 5.4.0? Is it safe for me to use an existing instance after fork(), or should I free and recreate my instance on each child process?

Thanksss!!1 ✨

djmitche commented 2 years ago

You're right -- that warning about unicorn is outdated.