监控目录进行更改 - 潜在的高内存 [英] Monitoring directory for changes - potential high memory

查看:108
本文介绍了监控目录进行更改 - 潜在的高内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在nodeJS中使用一个脚本来监视一个目录(它是子目录),一旦文件放在那里就执行一些功能。实际上,这将是一个FTP,用户上传文件,然后被处理,然后被删除。

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.

显然,我已经看到CPU用量很高该脚本遍历目录,等待文件可见。但是令我担心的是脚本运行的时间越长,内存使用量越高(它只是呈指数级上升)。有没有一些轻量级的方式来监控目录的变化?

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?

谢谢!

编辑:我目前使用很棒的观赏树,但仍然存在着越来越多的内存问题。 p>

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

推荐答案

听起来你想要一个包装在FAM或inotify周围。也许像 node-inotify-plusplus 这样的东西可以为你工作。

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

这篇关于监控目录进行更改 - 潜在的高内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆