Monitoring directory for changes - potential high memory

淺唱寂寞╮ 提交于 2019-12-21 04:13:10

问题


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:


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



来源:https://stackoverflow.com/questions/5877263/monitoring-directory-for-changes-potential-high-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!