Monitoring directory for changes - potential high

2020-06-16 03:05发布

I'm currently using a script in nodeJS to monitor a directory (and it's sub directories), and do some function once a file has been placed there. In reality, this would be an FTP, where users upload files, it is processed, then deleted.

Obviously, i'm already seeing some high amount in CPU usage with the script, as it traverses over the directories, waiting for files to be visible. But what worries me is that the longer the script runs, the higher the memory usage (it just keeps rising exponentially). Are there some lightweight ways to monitor a directory for changes?

Thanks!

EDIT: I'm currently using watch-tree which is great, but still has the increasing-memory issue.

1条回答
仙女界的扛把子
2楼-- · 2020-06-16 04:03

Sounds like you want a wrapper around FAM or inotify. Maybe something like node-inotify-plusplus would work for you.

查看更多
登录 后发表回答