Code Monkey home page Code Monkey logo

Comments (6)

srod avatar srod commented on June 4, 2024

It seems to be failing when deleting the temporary file.
I don't think that is related to the cluster.
Can you show me the content of your minify.js ?

from node-minify.

JeffML avatar JeffML commented on June 4, 2024

It only happens when clustering, and then only intermittently. At first I thought it might be a shared ./tmp directory, but renaming it didn't help. Also didn't matter which compressor I used.

minify.js:

/* concatenate and minify js, css files */
var compressor = require('node-minify')
,async = require('async')
;

module.exports = minify = function(options, callback) {
var cssCompress = options.compress? 'yui-css' : 'no-compress'; // Using YUI Compressor for CSS
var jsCompress = options.compress? 'uglifyjs' : 'no-compress'; // Using UglifyJS Compressor for JS

async.parallel([
    function(cb) {
        new compressor.minify({
            type: cssCompress,
            tempPath: 'tmp/',
            fileIn: [
        //...
            ],
            fileOut: '../htdocs/css/min/base.css',
            callback: cb
        })
    },
    function(cb) {
        new compressor.minify({
            type: cssCompress,
            tempPath: 'tmp/',
            fileIn: [
        //...
            ],
            fileOut: '../htdocs/css/min/spry.css',
            callback: cb
        })
    },


     function(cb) {
        new compressor.minify({
            type: jsCompress,
            tempPath: 'tmp/',
            fileIn: [
        //...
                ],
            fileOut: '../htdocs/javaScript/min/core_min.js',
            callback: cb
        })
    },

    function(cb) {
        new compressor.minify({
            type: jsCompress,
            tempPath: 'tmp/',
            fileIn: [
        //...
                ],
            fileOut: '../htdocs/javaScript/min/core_deferred_min.js',
            callback: cb
        })
    },

    function(cb) {
        new compressor.minify({
            type: jsCompress, 
            tempPath: 'tmp/',
            fileIn: [
        //...
                ],
            fileOut: '../htdocs/javaScript/min/login_deferred_min.js',
            callback: cb
        })
    },

    function(cb) {
        new compressor.minify({
            type: jsCompress,
            tempPath: 'tmp/',
            fileIn: [
        //...
                ],
            fileOut: '../htdocs/javaScript/min/review_deferred_min.js',
            callback: cb
        })
    },

    function(cb) {
        new compressor.minify({
            type: jsCompress,
            tempPath: 'tmp/',
            fileIn: [
        //...
                ],
            fileOut: '../htdocs/javaScript/min/spry_min.js',
            callback: cb
        })
    }
], callback

)};

if (!module.parent) { //running standalone
var isCompress = process.argv.indexOf('nocompress') == -1;

minify({compress: isCompress}, function(err, results){
    if(err) console.log(err);
});

}

On Mar 11, 2014, at 12:01 PM, Rodolphe Stoclin wrote:

It seems to be failing when deleting the temporary file.
I don't think that is related to the cluster.
Can you show me the content of your minify.js ?


Reply to this email directly or view it on GitHub.

from node-minify.

srod avatar srod commented on June 4, 2024

I have just release 0.9.2, can you test with it ?
And also, the cluster is firing your minify for each cluster.
You have to do that in the master instead.
Here what I was testing and work well :

(function(){
  var cluster = require('cluster'),
    numCPUs = require('os').cpus().length;

  if (cluster.isMaster) {
    minify({compress: true}, function(){
      console.log('ok compress');
    });

    // Fork workers
    for (var i = 0; i < numCPUs; i++) {
      var worker = cluster.fork();
    }

    cluster.on('death', function (worker) {
      var newWorker = cluster.fork();
    });
  } else {
        var port = parseInt(config['port']);
        server.listen(port);
  }
})();

from node-minify.

JeffML avatar JeffML commented on June 4, 2024

Oh, thanks for explaining that. I hadn't realized each process was re-executing the whole script. I will try 0.9.2 later today.

-- Jeff

On Mar 12, 2014, at 11:06 AM, Rodolphe Stoclin wrote:

I have just release 0.9.2, can you test with it ?
And also, the cluster is firing your minify for each cluster.
You have to do that in the master instead.
Here what I was testing and work well :

(function(){
var cluster = require('cluster'),
numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
minify({compress: true}, function(){
console.log('ok compress');
});

// Fork workers
for (var i = 0; i < numCPUs; i++) {
  var worker = cluster.fork();
}

cluster.on('death', function (worker) {
  var newWorker = cluster.fork();
});

} else {
var port = parseInt(config['port']);
server.listen(port);
}
})();

Reply to this email directly or view it on GitHub.

from node-minify.

JeffML avatar JeffML commented on June 4, 2024

0.9.3 works like a charm.

On Mar 12, 2014, at 11:06 AM, Rodolphe Stoclin wrote:

I have just release 0.9.2, can you test with it ?
And also, the cluster is firing your minify for each cluster.
You have to do that in the master instead.
Here what I was testing and work well :

(function(){
var cluster = require('cluster'),
numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
minify({compress: true}, function(){
console.log('ok compress');
});

// Fork workers
for (var i = 0; i < numCPUs; i++) {
  var worker = cluster.fork();
}

cluster.on('death', function (worker) {
  var newWorker = cluster.fork();
});

} else {
var port = parseInt(config['port']);
server.listen(port);
}
})();

Reply to this email directly or view it on GitHub.

from node-minify.

srod avatar srod commented on June 4, 2024

Glad to hear that :)

from node-minify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.