Skip to content

Add after_child_ready hook - #220

Merged
hmcguire-shopify merged 1 commit into
Shopify:masterfrom
serenaf:serena/after-mold-ready-hook
Nov 19, 2026
Merged

hmcguire-shopify merged 1 commit into
Shopify:masterfrom
serenaf:serena/after-mold-ready-hook

Conversation

@serenaf

@serenaf serenaf commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Adds an after_child_ready hook, called in the monitor whenever a worker, service or mold reports ready. Outdated molds discarded by the monitor don't trigger it.

Also exposes Worker#spawned_at so the hook can measure child boot time.
Use case: emitting a metric when a new mold successfully finishes loading the app.

Comment thread lib/pitchfork/http_server.rb Resolved
@serenaf
serenaf force-pushed the serena/after-mold-ready-hook branch from ac72c45 to 04dbb2f Compare October 29, 2026 11:02

@byroot byroot left a comment

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.

Comment thread lib/pitchfork/http_server.rb Resolved
@serenaf
serenaf force-pushed the serena/after-mold-ready-hook branch from 04dbb2f to 26ea8a8 Compare October 29, 2026 12:14
Comment thread lib/pitchfork/worker.rb
@monitor = nil
@exiting = false
@requests_count = 0
@spawned_at = Pitchfork.time_now

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.

We just experimented with this in production, it works well for workers, but for molds the timing seem very off, I'll try to figure it out.

@serenaf
serenaf force-pushed the serena/after-mold-ready-hook branch 3 times, most recently from 261f4f8 to a0ff9e0 Compare November 19, 2026 10:04
@byroot

byroot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

cc @rafaelfranca no rush, but this patch would be very nice to have for us (allow to instrument boot time and worker spawn time more cleanly).

Also persist Worker#spawned_at across restarts and preserve the
initial mold's spawned_at record.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@serenaf
serenaf force-pushed the serena/after-mold-ready-hook branch from a0ff9e0 to f2dcb51 Compare November 19, 2026 17:35
@hmcguire-shopify
hmcguire-shopify merged commit f53a292 into Shopify:master Nov 19, 2026
25 of 26 checks passed
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.

3 participants