-
Notifications
You must be signed in to change notification settings - Fork 314
Description
Is your feature request related to a problem? Please describe.
A user can't make use of the default behavior of signals in Go programs because we always register signal handlers.
I would like to use the app lifecycle without it registering a signal handler.
Describe the solution you'd like
A clear and concise description of what you want to happen.
- Add an Option to App that opts-out of registering the signal receiver.
This should be an easy change:
- Add an option that sets
signalReceivers.{notify,stopNotify}
to no-ops. - Add docs around option.
Happy to add once their's consensus.
Describe alternatives you've considered
I use fx as part of my library go-libp2p. An alternative is to expose the app.Done
in my constructed object and let the user handle the signal explicitly this way. The problem with this approach is that it changes the standard way signal handling works in Go. User's should just concern themselves with signal.Notify
rather than having to know that app.Done
has registered a signal handler for them. And if the user hasn't registered with signal.Notify
they would expect the default behavior from Go.
Is this a breaking change?
We do not accept breaking changes to the existing API. Please consider if your proposed solution is backwards compatible. If not, we can help you make it backwards compatible, but this must be considered when we consider new features.
No. It can be provided as an option. The default can remain the same.
Additional context
See related issues in go-libp2p:
- Process unresponsive to SIGINT libp2p/go-libp2p#2785
- One proposed PR, but I'd favor the ability to opt-out in fx: fix: Close host on SIGINT libp2p/go-libp2p#2829 (comment)