Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LifecycleHandler::pre_new_process #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bobrik
Copy link

@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.

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