Sails js应用程序将CPU使用率提高到100% [英] Sails js application driving CPU usage to 100%
问题描述
我正在使用Sails构建应用程序,每当我让服务器运行超过几分钟时,我的CPU就会稳定地达到100%的使用率.我的资产中包含的文件数量减少了很多,我相信我的问题就在这里.还有其他可能的原因吗?
I'm building a an application using sails and every time I leave the server running for more than a few minutes my CPU jumps to a solid 100% usage. I'm including a big amount of less files in my assets and I believe my issue lies here. Are there any other reasons this may happen?
推荐答案
当您有很多文件时,它可能会压缩您的CPU.尝试禁用该功能,然后检查您的CPU是否正常使用(6-30%取决于您的CPU和总体使用情况).
It could be the grunt-watch, when you have a lot of files it squeezes your cpu. Try disabling that and check if your cpu gets to a normal usage (6-30% depending on your cpu and overall usage).
要执行此操作,请转到tasks/register/default.js
,然后从阵列中删除'watch'
.
To do that go to tasks/register/default.js
and remove 'watch'
from the array.
module.exports = function (grunt) {
grunt.registerTask('default', ['compileAssets', 'linkAssets', 'watch']);
};
如果您不想完全禁用grunt watcher,请转至tasks/config/watch.js
并尝试排除包含大部分文件的文件夹,或者如果它们不在特定文件夹中,则排除所有文件.
If you don't want to completely disable the grunt watcher, then go to tasks/config/watch.js
and try excluding the folder that has most of your files, or exclude them all if they are not in a particular folder.
我将为您提供一个示例,说明如何为该任务排除文件夹.只需在要排除的路径之前添加!
.
I'll give you an example of how to exclude a folder for this task. Just add a !
before the path you want to exclude.
module.exports = function(grunt) {
grunt.config.set('watch', {
// Some config you can ignore in this case
assets: {
// Assets to watch:
files: ['assets/**/*',
'tasks/pipeline.js', '!**/node_modules/**',
'!assets/folder-to-exlude/**' // <-- HERE IS THE EXCLUDED PATH
],
// More code
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
};
我遇到了类似的问题,这对我有用,请让我知道它是否有效.
I had a similar issue and this worked for me, let me know if it works.
这篇关于Sails js应用程序将CPU使用率提高到100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!