简体   繁体   English

Node.js中的“Autoconfig”和“守护进程”任务

[英]“Autoconfig” and “Daemon” Tasks in Node.js

My server guy wants to use apache, and also he wants to program a daemon to control automated file deletion, along with other automated file tasks. 我的服务器人想要使用apache,并且他还希望编写一个守护进程来控制自动文件删除以及其他自动文件任务。 Can node.js automate the deletion of files if they reach a certain length of time? 如果文件达到一定的时间长度,node.js可以自动删除文件吗? And in addition, can node.js time-stamp, because my server guy swears it cannot, and that "daemons are superior for automated file tasks!" 另外,node.js可以加上时间戳,因为我的服务器人发誓它不能,而且“守护进程对自动文件任务来说更胜一筹!”

Thank you. 谢谢。

Sorry if my question isn't very comprehensible, I'm in a hurry to get this answered. 对不起,如果我的问题不是很清楚,我急着得到这个答案。

Yes, here you can find how. 是的, 在这里你可以找到。

For such tasks, I think that cron job that executes some script (it can be a nodejs, php, perl, sh, whatever) can work just fine. 对于这样的任务,我认为执行一些脚本的cron作业(它可以是nodejs,php,perl,sh,等等)可以正常工作。

At the end, depends on your problem. 最后,取决于你的问题。 Daemon sound like an overkill, but it might be the only approach. 守护进程听起来像是一种矫枉过正,但它可能是唯一的方法。

One way to use node might be to use inotify/dnotify to be notified when files are created, then set callbacks with setTimeout to clear them, or keep a list and periodically iterate it and delete files. 使用节点的一种方法可能是使用inotify / dnotify在创建文件时得到通知,然后使用setTimeout设置回调以清除它们,或保留列表并定期迭代它并删除文件。 The distinction between a daemon and node is not correct, a node application can be a daemon or a one-off script. 守护程序和节点之间的区别不正确,节点应用程序可以是守护程序或一次性脚本。 Node just keeps running until no further interrupts are possible and then the script terminates. 节点只是一直运行,直到无法进一步中断,然后脚本终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM