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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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).
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']);
};
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.