concordusapps / grunt-haml

Process HAML templates to precompiled JavaScript or rendered HTML.
https://npmjs.org/package/grunt-haml
MIT License
41 stars 28 forks source link

Limit number of haml processes run together #34

Open nikhilvij opened 9 years ago

nikhilvij commented 9 years ago

Currently this plugin issues command to run haml commands corresponding to all haml files at once. This causes my server to crash when I run grunt-haml while deploying.

At one point I noted that there were more than 60 simultaneous haml processes.

It would be good, if we could run these processes sequentially or cap the number of processes being run simultaneously.

PS: I am using haml gem, i.e. ruby haml.

nikhilvij commented 9 years ago

Looked around a bit, and found that there is an async plugin in grunt, which has functions like series which can be used instead of async.forEach(this.files, function(file, callback) {... on line 55

mehcode commented 9 years ago

https://github.com/caolan/async#eachlimitarr-limit-iterator-callback

async.eachLimit

Seems like what we want here. Maybe set the limit to a default of require('os').cpus().length * 2 with some option to override it.


Thank you for submitting this. I'll put this on my list to look at it but if you'd like to submit a pull request it'll likely get done much faster.

nikhilvij commented 9 years ago

thanks for that default suggestion. Slightly new to grunt so didn't know we could access number of cores. Will submit a PR. Although I am new to grunt, so might not be written well.