Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Filesystem watching #558

Merged
merged 13 commits into from
Apr 25, 2018
Merged

Filesystem watching #558

merged 13 commits into from
Apr 25, 2018

Conversation

r8d8
Copy link
Member

@r8d8 r8d8 commented Apr 10, 2018

No description provided.

@whilei
Copy link
Contributor

whilei commented Apr 23, 2018

Just a couple notes:

  1. config.Watchdog is neither tested nor actually implemented -- is this ok?
  2. currently the external configuration file lives at <chaindir>/chain.json, which is adjacent to chaindata/, keystore/, and other directories; we'll need to require configuration change around chain config file space if the watcher watches a directory, or we just have to use the includes field?
  3. @r8d8 can you please change the branch to be upstream:issue/fs_watch?

@r8d8 r8d8 closed this Apr 24, 2018
@r8d8 r8d8 reopened this Apr 24, 2018
whilei
whilei previously requested changes Apr 24, 2018
Copy link
Contributor

@whilei whilei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding 1: I think it's ok to not implement it's use case for requiredHash yet, but would like a test. So, for example, it'll be obvious if https://github.com/ethereumproject/go-ethereum/pull/558/files#diff-5f06923a4803a1d0c02fce9f582d0495R36 is intentional or not.

Regarding 2: according to https://github.com/fsnotify/fsnotify#faq the watcher does not watch directories recursively, so if pointed at <datadir>/<chaindir>/ we don't have to worry about filtering a ton of chaindata/ events or anything like that. 👍

Regarding 3: r8d8 has notified me that maintainers have been given push permissions to the PR branch.

log.Println("event:", event)
if event.Op&fsnotify.Write == fsnotify.Write {
log.Println("modified file:", event.Name)
//cw.notify <- event
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be commented?

"github.com/fsnotify/fsnotify"
)

type configWatchdog struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might suggest to rename this (and the file) to something more general instead of "config*", like maybe dirWatchdog/dirwatcher.go? -- the functionality implemented could be used to watch any directory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, sounds reasonable

@@ -343,15 +345,17 @@ func main() {
// It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down.
func geth(ctx *cli.Context) error {
//_, err := core.NewConfigWatchdog("")
Copy link
Contributor

@whilei whilei Apr 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A leftover debugging comment?

log.Println("modified file:", event.Name)
//cw.notify <- event
}
case err := <-cw.watcher.Errors:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to handle watcher errors besides logging, too. Maybe they just get sent thru the cw.notify chan too, then we'll check for and handle them during event notifier filtering?

case event := <-cw.watcher.Events:
log.Println("event:", event)
if event.Op&fsnotify.Write == fsnotify.Write {
log.Println("modified file:", event.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick with using glog.[D|V] plz ;)


// Stop config directory watching
func (cw *configWatchdog) Stop() error {
return cw.watcher.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also close cw.notify chan? Go channels typically won't cause problems if they're not explicitly closed, but would encourage and force us to be explicit about channel flow.


// Start config directory watching
func (cw *configWatchdog) Start() {
go func() {
Copy link
Contributor

@whilei whilei Apr 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/fsnotify/fsnotify#faq -> howeyc/fsnotify#7 -> golang/go#8282 (comment) it might be unsafe to watch Events and Errors in the same go routine.

* config file watching, "requiedHash" support

* vendor fsnotify (and update some dependencies)
@tzdybal tzdybal changed the base branch from master to sidekick_poc April 25, 2018 14:52
@r8d8 r8d8 changed the title [WIP] Filesystem watching Filesystem watching Apr 25, 2018
@r8d8 r8d8 merged commit d71431f into ethereumproject:sidekick_poc Apr 25, 2018
@r8d8 r8d8 deleted the issue/fs_watch branch May 10, 2018 13:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants