Skip to content

API to stop the file watcher #1404

Open
@skidder

Description

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Problem Description

I'd like to be able to stop the file watcher created by calling Viper.WatchFile(). Being able to gracefully tear down the filewatcher helps to ensure a clean shutdown without possible invocations of the onConfigChange function.

Proposed Solution

Add a Golang context and cancel-function to the Viper struct type. Move the events waitgroup (eventsWG) from the watcher go-routine to the Viper struct type. Initialize these fields in the WatchConfig() function. Add a Viper.Stop() function that calls the cancel function to stop the watcher.

Alternatives Considered

No response

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions