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

Configuration reload #750

Open
5 tasks done
foxcpp opened this issue Jan 25, 2025 · 1 comment
Open
5 tasks done

Configuration reload #750

foxcpp opened this issue Jan 25, 2025 · 1 comment
Assignees
Milestone

Comments

@foxcpp
Copy link
Owner

foxcpp commented Jan 25, 2025

This is a major refactoring since maddy has a lot of state and resource handles to deal with.

Design overview

Current register - initialize pipeline is replaced with register - configure - start.

type Module interface {
  Configure(ctx context.Context, inlineArgs string, cfg *config.Map) error
  Start(ctx context.Context) error
  Close(ctx context.Context) error
}

All module instances are first registered, then lazily configured. After that, all modules are started. If module is unused (and is therefore not configured) - startup fails (like now).

All instances are stored in a Registry object that replaces current global instances variable.

If module needs to access some exclusive resources - like BoltDB handler or TCP listener, the corresponding object is created and owner by a global resource holder.

When maddy is restarted, all resource holders are preserved, but Registry is created from scratch. All configuration loading is reexecuted, module instances are recreated. Module instances re-obtain existing resource handles from corresponding holders. Then modules are started. If any resource holders remain unused - they are closed.

Network listeners are dup'ed on return to modules. This is done because the only way to interrupt running Accept is to close to listener.

Plan

  • Register - Configure - Start module initialization
  • Non-global module registry
  • Resource holders
  • Network listener resource holders
  • Reinitialization with resource hand-over on SIGUSR1
@foxcpp foxcpp added this to the 0.9.0 milestone Jan 25, 2025
@foxcpp foxcpp self-assigned this Jan 25, 2025
@foxcpp
Copy link
Owner Author

foxcpp commented Jan 29, 2025

Merged to dev branch

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

No branches or pull requests

1 participant