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

[Feature Request] Automatically reload auth file #30

Closed
penguinpowernz opened this issue Apr 11, 2017 · 3 comments
Closed

[Feature Request] Automatically reload auth file #30

penguinpowernz opened this issue Apr 11, 2017 · 3 comments

Comments

@penguinpowernz
Copy link

penguinpowernz commented Apr 11, 2017

This feature assumes connections will be broken if server is restarted.

This would come in handy for building the auth file programmatically from a separate data source to avoid.

There's three ways we could do it in increasing levels of complexity:

  1. Reload every x second regardless
  2. Catch SIGUSR1 to trigger a reload
  3. Use inotify to trigger a reload when the file changes

Not sure which will be best.

@jpillora
Copy link
Owner

jpillora commented Apr 14, 2017

I think a poll every 5 seconds would be simplest. It's not a huge change, would you willing to send a PR?

These lines from server.go, can be moved into a function

		users, err := chshare.ParseUsers(config.AuthFile)
		if err != nil {
			return nil, err
		}
		s.Users = users

The function can run in a loop on a timer, it will need to be guarded with file change detection, and s.Users will need a sync.Mutex protecting it

@jpillora jpillora changed the title Live reloading of auth file [Feature] Automatically reload auth file Apr 14, 2017
@jpillora jpillora changed the title [Feature] Automatically reload auth file [Feature Request] Automatically reload auth file Apr 14, 2017
@penguinpowernz
Copy link
Author

Yea mate, I'll take a stab at it. Cheers

@jpillora
Copy link
Owner

jpillora commented Oct 20, 2018

Option 3. has been implemented in 1.2.4

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

No branches or pull requests

2 participants