Closed astutesoftware closed 8 years ago
sounds like you need to watch or poll the directory with readdir on an interval and make new watchers. i would probably key them off of the file path.
each tailfd
watcher only watches one file name. but it watches it even if its deleted and such that if it appears again the old watcher will start sending it's lines again.
i normally don't do folks homework for them but here is an exmaple. https://gist.github.com/soldair/e8d95fba17c7ac4e84da i have not tested it but it should mostly work.
I need to watch a bunch of log files. How can i do that. The number of watchers is dynamic. I determine it based on how many log files are in a pre-defined folder. Then for each of those files i need a watcher. Is using eval a bad option for dynamic watchers for each file? also How can get the name of the watcher in the function(line,tailInfo) so that i can identify which watcher fired it. or is there some way the function that fires for each line can pass me back the name of the file which is being watched so i can handle it accordingly.