Cowboy-coder / bundle-up

An asset manager for nodejs
MIT License
56 stars 22 forks source link

error when restarting node after bundle generation #1

Closed panosru closed 12 years ago

panosru commented 12 years ago

Hey, nice module!

I have an issue, as I see there node.js throws error in case generated/bundle/ folder is already there.

Cowboy-coder commented 12 years ago

That's odd. What version of node.js are you running and also, are you running on Windows or Linux/Os X?

Can you please post the bundle-up configuration code you are using when you are initializing the middleware as well as the error output you get from node.js?

panosru commented 12 years ago

Hi, thanks for your quick reply !

node version is 0.7.0-pre on Debian 6 64bit

a sample of my configuration with expressjs is this:

app.configure(function(){
  app.enable('case sensitive routes');
  app.enable('strict routing');
  app.set('views', $settings.paths.views);
  app.set('view engine', $settings.app.view.engine);
  app.use(express.favicon());
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser());
  app.use(express.session({ secret: $settings.app.session.secret }));

  BundleUp(app, $settings.paths.assets, {
    staticRoot : $settings.paths.public,
    staticUrlRoot : '/',
    bundle:true
  });

  app.use(require('./config/modul8'));
  app.use(app.router);
  app.use(express.static($settings.paths.public));
  app.use(_ErrorHanlder.Error404);
  app.use(_ErrorHanlder.Errors);
});

After more investigation on it while I'm writing my reply here it is supervisor's issue...

root@dev:/home/rnd/domains/design.rnd/public_html/app-ui# NODE_ENV=development supervisor -w . -p 1 -e "node|js|coffee|jade" app.js

DEBUG: Running node-supervisor with
DEBUG:   program 'app.js'
DEBUG:   --watch '.'
DEBUG:   --extensions 'node|js|coffee|jade'
DEBUG:   --exec 'node'

DEBUG: Starting child process with 'node app.js'
DEBUG: Watching directory '/home/rnd/domains/design.rnd/public_html/app-ui/.' for changes.
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child
DEBUG: Starting child process with 'node app.js'
DEBUG: crashing child

node.js:380
        throw errnoException(errno, 'kill');
              ^
Error: kill ESRCH
    at errnoException (node.js:230:13)
    at EventEmitter.kill (node.js:380:15)
    at Object._onTimeout (/usr/local/lib/node_modules/supervisor/lib/supervisor.js:149:13)
    at Timer.ontimeout (timers.js:84:39)

And the npm log output here:

info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'start' ]
info using npm@1.1.0-beta-10
info using node@v0.7.0-pre
verbose config file /root/.npmrc
verbose config file /usr/local/etc/npmrc
verbose config file /usr/local/lib/node_modules/npm/npmrc
verbose caching /home/rnd/domains/design.rnd/public_html/app-ui/package.json
verbose loadDefaults application-name@0.0.1
verbose run-script [ 'prestart', 'start', 'poststart' ]
info prestart application-name@0.0.1
info start application-name@0.0.1
verbose unsafe-perm in lifecycle true
silly exec sh "-c" "NODE_ENV=development supervisor -w . -p 1 -e \"node|js|coffee|jade\" app.js"
silly spawning [ 'sh',
silly spawning   [ '-c',
silly spawning     'NODE_ENV=development supervisor -w . -p 1 -e "node|js|coffee|jade" app.js' ],
silly spawning   '/home/rnd/domains/design.rnd/public_html/app-ui' ]
info application-name@0.0.1 Failed to exec start script
ERR! application-name@0.0.1 start: `NODE_ENV=development supervisor -w . -p 1 -e "node|js|coffee|jade" app.js`
ERR! `sh "-c" "NODE_ENV=development supervisor -w . -p 1 -e \"node|js|coffee|jade\" app.js"` failed with 1
ERR! 
ERR! Failed at the application-name@0.0.1 start script.
ERR! This is most likely a problem with the application-name package,
ERR! not with npm itself.
ERR! Tell the author that this fails on your system:
ERR!     NODE_ENV=development supervisor -w . -p 1 -e "node|js|coffee|jade" app.js
ERR! You can get their info via:
ERR!     npm owner ls application-name
ERR! There is likely additional logging output above.
ERR! 
ERR! System Linux 2.6.32-5-amd64
ERR! command "node" "/usr/local/bin/npm" "start"
ERR! cwd /home/rnd/domains/design.rnd/public_html/app-ui
ERR! node -v v0.7.0-pre
ERR! npm -v 1.1.0-beta-10
ERR! code ELIFECYCLE
ERR! message application-name@0.0.1 start: `NODE_ENV=development supervisor -w . -p 1 -e "node|js|coffee|jade" app.js`
ERR! message `sh "-c" "NODE_ENV=development supervisor -w . -p 1 -e \"node|js|coffee|jade\" app.js"` failed with 1
verbose exit [ 1, true ]

node app.js works fine but without supervisor development becomes a bit more annoying because you will need to restart manually node after each change...

Thank you for your time!

Cowboy-coder commented 12 years ago

Yeah it looks like a supervisor issue.. I wouldn't recommend running node.js 0.7.0 pre though unless you got a real reason to. It's a very unstable release of node.js from what I've understood. 0.6.x is the current stable version of node.js.

panosru commented 12 years ago

@Cowboy-coder hi, I run it only locally since I haven't used node.js in production yet, if you noticed my path says rnd which is what I'm doing :) so far node 0.7.0-pre runs quite nice for me but I assume by the time I'll be ready for production 0.7.0 will be stable thus I run 0.7.0-pre in development env :)

Do you see if there is a way to fix current module to work with supervisor?

Thanks

Cowboy-coder commented 12 years ago

Sure, I'll look into it! In the meantime you could try out https://github.com/remy/nodemon if you want. I've been using it successfully with BundleUp for a time now. As long as you add a .nodemonignore file with your generated/ directory so that it doesn't restart the process when files are added to that directory.

panosru commented 12 years ago

@Cowboy-coder Thank you again! I will use nodemon for now although I don't know how to make it watch for coffee and jade extensions but at least it will work...

For those who might bump into that, supervisor have a pull request which add's support for --ignore flag so it could be used to ignore generated folder in the future, for now nodemon is the way to go :)

Thanks!

Cowboy-coder commented 12 years ago

We're using nodemon with coffee-script and Jade. You don't need to restart the server when editing Jade files (just add *.jade to .nodemonignore) and you should be able to use nodemon out of the box with coffee-script by just nodemon server.coffee.

panosru commented 12 years ago

Thanks mate! :)