Skip to content

Ensure events send out after being forked - #50

Merged
travisjeffery merged 6 commits into
masterfrom
fix-threads
May 14, 2014
Merged

Ensure events send out after being forked#50
travisjeffery merged 6 commits into
masterfrom
fix-threads

Conversation

@travisjeffery

Copy link
Copy Markdown
Contributor

This ensures that the threads that the event requests are on run after their process has been forked.

For people using forking servers like unicorn and passenger, they no longer have to setup the sdk again with:

Comment thread lib/segment/analytics/client.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need this so the thread gets properly GC'd: #27

@calvinfo

Copy link
Copy Markdown
Contributor

niiiiiiice! :D this looks really sweet.

only concern that I have is if they do something like:

analytics.init('secret')
analytics.track(...)

== FORK ==

analytics.track(...)

since the thread might still be "alive" but not actually synced with the right "queue" properly when the memory is copied.

if that case works, lgtm!

travisjeffery added a commit that referenced this pull request May 14, 2014
Ensure events send out after being forked
@travisjeffery
travisjeffery merged commit d6ae66f into master May 14, 2014
@travisjeffery
travisjeffery deleted the fix-threads branch May 14, 2014 19:58
@jtippett

Copy link
Copy Markdown

So to clarify - does this mean unicorn, et al users no longer have to re-init analytics-ruby after forking?

@toothrot

Copy link
Copy Markdown

This is pretty amazing. You should blog about this solution. I think it's a great pattern for lots of background threading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants