Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grunt watch using lots of cpu on Ubuntu 12.04

I'm using grunt to watch my coffeescript files in a towerjs project and recompile them as they change. The configuration for this is generated by towerjs and seems fairly sane. The problem is, that once I start this process I will see it pegging a cpu core (actually, just one hyperthread). If I remove a lot of the paths from being watched I can get it down to around 25% of a CPU, but that is still pretty terrible.

I've found a few references to some known issues and cross-platform inconsistence with the Node's fs API and even the fs.watch in particular. Tried grunt-simple-watch but it did not do any better.

I could setup Guard but it may be fiddlesome to get it working just right and functionally grunt seems to be just fine - I am curious though if anyone else has any other suggestions.

like image 606
Jeremy Avatar asked Oct 07 '22 07:10

Jeremy


1 Answers

Give the new watch task a try: npm install grunt-contrib-watch and add grunt.loadNpmTasks('grunt-contrib-watch'); to your gruntfile. The Grunt v0.3 watch task traverses & stats files which with a large number of files can get slow but was necessary for system compatibility. The new one will only use inotify if working properly within node.

like image 132
Kyle Robinson Young Avatar answered Oct 10 '22 02:10

Kyle Robinson Young