Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring directory for changes - potential high memory

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.

like image 774
crawf Avatar asked May 04 '11 00:05

crawf


1 Answers

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

like image 151
rjp Avatar answered Nov 15 '22 01:11

rjp