A stopped tool drops its membership handler and a stopped bundle starts no copy on a call, so a replaced bundle's old tools stay gone (issue 1945, review round 2)
mesh/delivery merged: source.main moved to novox/mesh-tools@5d6cee9d844e
mesh/check pass 2cd5550dc70f on 77b05089c8df | unit 0 run 126 kept | int 0 run 128 kept | clone 9.5s | composition passed on 4 machines
mesh/delivery merged: source.main moved to novox/mesh-tools@5d6cee9d844e
mesh/check pass 2cd5550dc70f on 77b05089c8df | unit 0 run 126 kept | int 0 run 128 kept | clone 9.5s | composition passed on 4 machines
Its events are refused before the old bundle stops, the bundle watch follows a directory made between its stat and its watch, and a bundle's reason is read without node's colour codes.
This commit is contained in:
@@ -61,26 +61,40 @@ func watchBundles(paths []string, changed func(), logf func(string, ...any)) (fu
|
||||
}
|
||||
|
||||
// arm watches, for every entrypoint, its directory, or the nearest directory above it that exists. A
|
||||
// watch already held on the same directory is kept (inotify answers its descriptor again).
|
||||
// watch already held on the same directory is kept (inotify answers its descriptor again). A directory
|
||||
// made below the watched one between its stat and its watch would be heard by nobody, so after each watch
|
||||
// the path is looked at again, and a deeper directory that came to be is watched in turn.
|
||||
func (w *bundleWatch) arm() {
|
||||
for _, p := range w.paths {
|
||||
dir := filepath.Dir(p)
|
||||
target := filepath.Dir(p)
|
||||
watched := ""
|
||||
for {
|
||||
if info, err := os.Stat(dir); err == nil && info.IsDir() {
|
||||
dir := nearestDir(target)
|
||||
if dir == watched {
|
||||
break
|
||||
}
|
||||
up := filepath.Dir(dir)
|
||||
if up == dir {
|
||||
wd, err := unix.InotifyAddWatch(w.fd, dir, watchMask)
|
||||
if err != nil {
|
||||
w.logf("[mesh-tools] cannot watch %s for %s's bundle: %v; a bundle placed or changed there is served only after a restart", dir, p, err)
|
||||
break
|
||||
}
|
||||
dir = up
|
||||
w.byWD[wd] = dir
|
||||
watched = dir
|
||||
}
|
||||
wd, err := unix.InotifyAddWatch(w.fd, dir, watchMask)
|
||||
if err != nil {
|
||||
w.logf("[mesh-tools] cannot watch %s for %s's bundle: %v; a bundle placed or changed there is served only after a restart", dir, p, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// nearestDir is dir when it is a directory, else the nearest directory above it.
|
||||
func nearestDir(dir string) string {
|
||||
for {
|
||||
if info, err := os.Stat(dir); err == nil && info.IsDir() {
|
||||
return dir
|
||||
}
|
||||
w.byWD[wd] = dir
|
||||
up := filepath.Dir(dir)
|
||||
if up == dir {
|
||||
return dir
|
||||
}
|
||||
dir = up
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user