Skip to content

Add LifecycleHandler::pre_new_process#6

Merged
cbranch merged 1 commit into
cloudflare:mainfrom
bobrik:ivan/pre-new-process
Oct 1, 2024
Merged

Add LifecycleHandler::pre_new_process#6
cbranch merged 1 commit into
cloudflare:mainfrom
bobrik:ivan/pre-new-process

Conversation

@bobrik
Copy link
Copy Markdown
Contributor

@bobrik bobrik commented Sep 26, 2024

My ultimate goal is to persist some state on reloads and graceful shutdown to allow the next generation to use that data. I want to be able to restore this state on reboots and crashes. The actual state is the list of cache keys to prewarm, so it's ok to have it a bit stale. It is not ok to have it empty.

When storing state in a file:

  • Reading the state happens on startup, no support necessary.
  • Writing needs to happen before the next generation of the process starts:
    • For graceful upgrades this pre_new_process() hook should do the trick.
    • For graceful shutdowns there would be some other thing outside of shellflip.
    • For crashes we live with stale data.

Passing the data in send_to_new_process doesn't feel right for this, but I might be persuadable. The reason I don't like it is because there would be a split in behavior on startup:

  • If there's data from the parent, save it to persistent storage (some file).
  • If it's a cold start without a parent, restore the data from persistent storage.

@cbranch cbranch merged commit 907136d into cloudflare:main Oct 1, 2024
@bobrik bobrik deleted the ivan/pre-new-process branch October 1, 2024 22:43
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.

2 participants